小编Tim*_*ens的帖子

正则表达式,用于检测以星号开头的行

下面的代码无法检测出现的单个实例.= O什么错了?= \

如何检测以星号开头的以下行(以换行符开头)?我不知所措.这不符合我的预期.

$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);
Run Code Online (Sandbox Code Playgroud)

php regex preg-match-all preg-match

3
推荐指数
1
解决办法
423
查看次数

标签 统计

php ×1

preg-match ×1

preg-match-all ×1

regex ×1