View Single Post
Old 12-09-2007, 03:42 PM   #24 (permalink)
Geert
The Contributor
RegEx Guru 
 
Geert's Avatar
 
Join Date: Dec 2007
Location: Belgium
Posts: 58
Thanks: 5
Geert is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
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 
Geert is offline  
Reply With Quote