Thank you very much for your quick answer!

Le 04-09-09, à 10:10, John Holmes a écrit :

From: "François Moreau" <[EMAIL PROTECTED]>

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
[snip]
$new_str = preg_replace_callback('#<b>.*</b>#Uis','myreplace',$str);

The # characters simply start and end the pattern. You can use any character for that, really. I normally use /, but since it's present in the pattern "</b>" and I didn't want to escape it, I used the # character.


The characters after the pattern delimiters are called pattern modifiers. They are explained here (http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php), but for the afraid-to-clicky-people:

U - ungreedy (makes sure the .* in the pattern doesn't match too much)
i - case-insensitive matching (in case you use <B> and </B>)
s - makes the dot character match newlines as well, otherwise text between bold tags that included newlines wouldn't be matches.


---John Holmes...


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to