PHP regex to search across multiple lines
Posted
by Gaz
on Stack Overflow
See other posts from Stack Overflow
or by Gaz
Published on 2010-05-20T06:34:51Z
Indexed on
2010/05/20
6:40 UTC
Read the original article
Hit count: 229
I'm using preg_* in PHP to search for the pattern <!-- %{data=THIS GETS MATCHED}% -->
and pull out the matched text.
The pattern for this is:
preg_match('#<!-- %{' . $knownString . '\s*=\s*(.*?)}% -->#', ...)
What I would like it to do is search across multiple lines for the string. For example:
<!-- %{data=
THIS GETS
MATCHED AND
RETURNED
}% -->
How can I edit my current pattern to have this search ability?
© Stack Overflow or respective owner