I'm using a wordpress plugin which will search and replace HTML using regular expression. You simply input something in a Search box, and something in a replace box. The type of regular expression is this.
I'm looking to do a relatively simple search and replace using regular expression which will be something like this (in plainish language).
Find content between and including two Search Strings:
SEARCH-STRING-A<-----Any-Content----->SEARCH-STRING-B
Replace All (including Search-String-A and Search-String-B With:
Any Text
Worked Example
Search Strings
Code:
Search-String-A = <div><a href="http://site.com">
Search-String-B = </img></a></div>
Replace With: <p>I rock!</p>
Example HTML original code:
Code:
<p>Blah blah blah blah</p>
<img src="http://url.com"></img>
<p>Blah blah blah!</p>
<div>
<a href="http://site.com">click here</a> and go to the site. Also see: <img src="http://picture.com"> </img>
</a> </div>
<p>Blah blah boo boo blah!</p>
After Search and Replace:
Code:
<p>Blah blah blah blah</p>
<img src="http://url.com"></img>
<p>Blah blah blah!</p>
<p>I rock!</p>
<p>Blah blah blah boo boo blah!</p>
The above search and replace must ignore any line breaks or white space in the HTML when looking for the occurence of the 'search string'.
Can anyone give the regular expression code that I will need to put into the Search box, and the replace box to get the above outcome?
Last edited by mrsolutions; 11-25-2008 at 12:38 PM..
|