下面的代码无法检测到该事件的单个实例。出什么事了?=
如何检测以下以星号开头的行(以换行开头)?我不知所措。这可不像我想象的那样。
$text ="Nothing here to detect...though it is the first line.
* '' [[test]]
* Another line that starts with an asterisk
** yet another...though it has two...but who cares about the 2nd one?";
$t = preg_match_all('#^\*.*#', $text, $match);
echo "found=".$t."\n";
print_r($match);
最佳答案
添加m
修饰符以指定它具有多行主题,如#^\*.*#m
http://php.net/manual/en/reference.pcre.pattern.modifiers.php