[thelist] Regular Expression help

Means, Eric D eric.d.means at boeing.com
Tue Jun 18 10:18:01 CDT 2002


>  -----Original Message-----
> From: 	Daniel Fascia [mailto:danfascia at totalise.co.uk]
> Sent:	Tuesday, June 18, 2002 10:07 AM
> To:	thelist at lists.evolt.org
> Subject:	[thelist] Regular Expression help
>
> Guys, Im trying to create a regular expression in PHP which will FIND and
REPLACE
> anything lying in between 2 tags Ive made..
>
> <!-- #CMS:Title --> .....this gets replaced..... <!-- #CMS:Title /-->

Using preg_replace (as I know Perl regexes better):

$html_body is the mass of HTML within which you want to replace the text.
$text_to_replace_with is the text you want in the given area after the
replace.

preg_replace ('/(<\!-- #CMS:Title -->).*?(<\!-- #CMS:Title \/-->)/', '\\1' .
$text_to_replace_with . '\\2', $html_body);

should do what you want (untested).



More information about the thelist mailing list