正则基础题

WBOY
WBOYOriginal
2016-06-23 13:52:48942browse

$url ="xxxxxxxxxxxxxxxxxxxxxx
,111111111111:
xxxxxxxxxxxxxxxxxxx";
    $preg = "/^,([0-9]+):$/im";
    preg_match_all($preg,$url,$a);
    print_r($a);    
?>

请问为何此例子在Window下无法正常匹配,而在Linux下正常匹配
是因为换行符不同 \n\r 和 \n 嘛?PHP正则基于Linux?
还是其他原因


回复讨论(解决方案)

你的理解是正确的,写成这样就通用了
$preg = "/^,([0-9]+):\s*$/im";

其实 : 就已经可以很好地判断结束了,不需要行尾 $
$preg = "/^,([0-9]+):/im";

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn