Home > Backend Development > PHP Tutorial > 正则基础题解决方案

正则基础题解决方案

WBOY
Release: 2016-06-13 12:03:30
Original
768 people have browsed it

正则基础题
$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";

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template