12-09-2007, 03:42 PM
|
#24 (permalink)
|
|
The Contributor
Join Date: Dec 2007
Location: Belgium
Posts: 60
Thanks: 6
|
Quote:
Originally Posted by Wildhoney
I was under the impression that the problem you mentioned above, Geert, was only applicable when regex was in multi-line - if you were to switch it over to single-line mode then the $ would match the end of the string and not before the new-line?
|
If you switch to multiline mode, by applying the m modifier, the D modifier is completely ignored. So $ will keep on matching before newlines as it does by default. However, you still could use \z.
PHP Code:
$str = "line1\nline2\n";
echo preg_match('/^line2$/m', $str); // TRUE
echo preg_match('/^line2$/mD', $str); // TRUE (D is ignored)
echo preg_match('/^line2\z/m', $str); // FALSE
|
|
|
|