This question already has an answer here:
Please tell me how to activate multi line functionality..and explain me how it work. (?m) or /m ?
$subject = "the brown fox jump bla
over the Lazy
dog ..Bla bla bla";
$matching = preg_match_all($regex1, $subject, $m);
$regex1 = '(?m)/^bla$\b/i';
print_r($m);
what to use and where? ...(?m) or /m ?
</div>
what to use and where? ...(?m) or /m
You can use either of them but you cannot use \b
(word boundary) after anchor $
. So use:
$regex1 = '/^bla$/im';
$subject = "the brown fox jump bla
over the Lazy
dog ..Bla bla bla";
preg_match_all($regex1, $subject, $m);
print_r($m);
And you need to declare regex before you can use it.
However none of you lines have just the text bla
hence your regex will fail to match anything.
Looking at your examples you may probably need:
$regex1 = '/\bbla$/im';
which will match line #1 and line #3.