Page 1 of 1

Regex question

Posted: Sat May 06, 2006 9:14 pm
by HiddenS3crets
Question using preg_match()

This is my current line:

Code: Select all

preg_match("/<([a-z])?\>(.*?)\<\/([a-z])?\>/", $str, $matches);
How can I have preg_match() return true if I have multiple lines submitted

Example:

Code: Select all

<php><? echo "hello world"; ?></php>
That submission will work, but if I do:

Code: Select all

<php><?
echo "hello world";
?></php>
it does not work. Any idea on how I can make it accept line breaks?

Posted: Sun May 07, 2006 2:52 am
by Oren
Assuming that this code works: (didn't read it)

Code: Select all

preg_match("/<([a-z])?\>(.*?)\<\/([a-z])?\>/", $str, $matches);
All you've got to do is to add the 's' modifier like this:

Code: Select all

preg_match("/<([a-z])?\>(.*?)\<\/([a-z])?\>/s", $str, $matches);

Posted: Sun May 07, 2006 5:30 am
by timvw