I have this data in a mysql field:
First text text text text
text text text text
text text text text text text
text text text text text text
Second text text text text
text text text text
text text text text text text
text text text text text text
I’m trying to preg match from the first word until the double line break. I’ve tried:
preg_match('/First(.*)\n\n/', $mysqlrow, $m);
This returns no rows. I’ve also tried the m and s modifiers, which don’t return the proper string. I’ve also tried \r\n which doesn’t return anything.
How do you do this
You need the
smodifier and you also need to change your wildcard quantifier to be non-greedy:The
soption will cause the.wildcard to match\nand the non-greedy will cause the*wildcard to not eat up all the\n\nit runs across before matching\n\n.You can also optionally match the
\rjust in case you have that in your database: