Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Multiline preg_match
- Paul Lautman
April 16, 2008, 9:04 pm
rate this thread
According to the manual, the default for preg_match is to treat the subject
string as consisting of a single "line" of characters (even if it actually
contains several newlines).
I want to match the "string" below to extract everyting from <strong> to
</div> (not inclusive).
However my attempt at preg_match('/<strong(.*)/',$fc,$match) returns only
Any suggestions welcome.
<html xmlns="http://www.w3.org/1999/xhtml ">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
2mm & 3mm<br />
~5.25”W x 3.25”H</div>
Re: Multiline preg_match
On Wed, 16 Apr 2008 23:04:14 +0200, Paul Lautman =
From the preg match portion of the manual:
. = match any character _except_newline_ (by default)
If this modifier is set, a dot metacharacter in the pattern
matches all characters, including newlines. Without it,
newlines are excluded.
In conclusion (giving you the bonus 'untill </div> non-inclusive'):
Which leaves me to say that while I'm a fan of regexes, I've given up =
using them on HTML, because a parser does a far more reliable, clearer, =
and most important more robust job.