php - 正则 匿名捕获 命名捕获
巴扎黑
巴扎黑 2017-04-10 15:42:18
0
1
377

深知正则表达式的威力最近学习一些,偶遇问题,废话不多说上代码:

$str = 'Mr.Ck-@139.com'; if(preg_match('(?:<#user>[a-zA-Z0-9_-.]+)@(?:<#host>[a-zA-Z0-9_-.]+)', $str, $match)) { print_r($match); } $str = '123,456,78,90'; if(preg_match('(?[0-9]+)(.(?[0-9]+))*', $str, $match)) { print_r($match); }

错误提示

Warning: preg_match(): Unknown modifier '@' in D:\webServ\index.php on line 15

Warning: preg_match(): Unknown modifier '(' in D:\webServ\index.php on line 23


我不知道是不是因为PHP函数的问题,我相信这个表达式应该是没问题的,只是preg_match这个函数的什么机制导致的把?

巴扎黑
巴扎黑

reply all (1)
迷茫

号码 最终问题 我解决了

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!