preg_replace_callback clarification
| From: | François Moreau | Date: | Thu, 09 Sep 2004 13:55:04 +0000 |
| Subject: | preg_replace_callback clarification | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-196215@lists.php.net to get a copy of this message | ||
The piece of code you have submitted (see under) is interesting, although there is one thing I don't find meaning to, even after RTFM, and STFG(Searching The Funky Google). In your regular expression pattern '#<b>.*</b>#Uis', what does this do : #...#Uis
Thank you very much
Piece of code :
[snip]
<?php
$str = 'This X and this X will not be fixed, but <b>this X
and</b> and hopefully this <b>X</b> should be, along <b> with
this X also. </b>, but not this X.';
function myreplace($match)
{
$from = 'X';
$to = 'Y';
return str_replace($from,$to,$match[0]);
}
$new_str = preg_replace_callback('#<b>.*</b>#Uis','myreplace',$str);
echo $new_str;
?>
[/snip]