Search Regex
can anyone help with regex replace syntax? (1 post)

  1. M One
    Posted 2 years ago #

    I need to clean the content of a wordpress site where the client has used the visual editor to style content across hundreds of pages resulting in a mess of nested span and style tags that need replacing with a simple class.

    For example - I need to replace:

    <h2 style="text-align: center;"><span style="color: #800080;"><strong>Page Heading</strong></span></h2>

    with the

    <h2 class="myclass">Page Heading</h2>

    I am using the regex search:

    @<h2 style="text-align: center;"><span style="color: #800080;"><strong>(.*?):</strong></span></h2>@

    This works but the replace @<h2 class="h2head">(.*?):</h2>@ does not - it just renders (.*?): instead of leaving the content between the tags intact as I want.

    Many thanks.


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Search Regex
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic