【发布时间】:2015-04-06 16:59:50
【问题描述】:
我正在使用 preg_match_all() 来匹配一些字符串。
这是我的代码
preg_match_all('@([a-zA-Z0-9,\(\)\-\s\.\#:]*)Date From: [0-9]{2}/[0-9]{2}/[0-9]{4}([, \s]*[0-9]{2}/[0-9]{2}/[0-9]{4})*\s(Division Type: [A-Z ]*)*@m', $string, $match);
这是输出
https://regex101.com/r/hE3iO2/1
现在,我想在第一个组中添加一个 / 以在捕获组中包含文字 /,这会发生
从这里
([a-zA-Z0-9,\(\)\-\s\.\#:]*)
到这里
([a-zA-Z0-9,\(\)\-\s\.\#:/]*)
https://regex101.com/r/wM1rW7/1
将/ 添加到组时如何防止这种情况发生?
【问题讨论】:
标签: php regex preg-match-all capturing-group