Regex activate multi line in php -
this question has answer here:
please tell me how activate multi line functionality..and explain me how work. (?m) or /m ?
$subject = "the brown fox jump bla on lazy dog ..bla bla bla"; $matching = preg_match_all($regex1, $subject, $m); $regex1 = '(?m)/^bla$\b/i'; print_r($m);
what use , where? ...(?m) or /m ?
what use , where? ...(?m) or /m
you can use either of them cannot use \b
(word boundary) after anchor $
. use:
$regex1 = '/^bla$/im'; $subject = "the brown fox jump bla on lazy dog ..bla bla bla"; preg_match_all($regex1, $subject, $m); print_r($m);
and need declare regex before can use it.
however none of lines have text bla
hence regex fail match anything.
looking @ examples may need:
$regex1 = '/\bbla$/im';
which match line #1 , line #3.
Comments
Post a Comment