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

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

'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}']

  

原文地址:https://www.cnblogs.com/mingc/p/7501693.html