Your expression will work with single lined data, if for some reason the content between your tags spanned multiple lines then the expression would not match.
Originally Posted by jeddik
I used [\w\W], but it's the same thing really.
. Matches any single character except "\n". To match any character including the '\n', use a pattern such as '[\s\S]'.
I'm not sure about how to pass extra parameters to a callback at the moment, I probably would have used a global variable, but I'm not going to say more about to save face :P
Last edited by bionoid; 12-23-2013 at 06:23 PM.
Note that you can add a "s" modifier after the closing regex delimiter to have the dot character include newlines.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
How to Ask Questions the Smart Way
(not affiliated with this site, but well worth reading)
OK - thanks to both.
I added/changed these lines then:
Seems to be working OK
$test_output2 = preg_replace_callback(
Good to know.
Originally Posted by NogDog
For anyone interested in the possible pattern modifiers: http://php.net/manual/en/reference.p....modifiers.php
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)