当前位置:Gxlcms > PHP教程 > ThinkPHP5中正则验证有“|”时提示“规则错误”的解决方案

ThinkPHP5中正则验证有“|”时提示“规则错误”的解决方案

时间:2021-07-01 10:21:17 帮助过:46人阅读

正则规则中有“|”时,会引起解析错误:

'regex:\d{3,4}[\s,-]?\d{7,8}|1[3,4,5,8]\d[\s,-]?\d{4}[\s,-]?\d{4}'

使用数组语法可以解决:

['regex' => '\d{3,4}[\s,-]?\d{7,8}|1[3,4,5,8]\d[\s,-]?\d{4}[\s,-]?\d{4}']

以上就是ThinkPHP5中正则验证有“|”时提示“规则错误”的解决方案的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行