When there is "|" in the regular rule, it will cause a parsing error:
'regex:\d{3,4}[\s,-]?\d{7,8}|1[3,4,5,8]\d[\s,-]?\d{4}[\s,-]?\d{4}'
Using array syntax can solve it:
['regex' => '\d{3,4}[\s,-]?\d{7,8}|1[3,4,5,8]\d[\s,-]?\d{4}[\s,-]?\d{4}']
The above is the detailed content of Solution to the 'Rule Error' prompt when there is '|' in regular verification in ThinkPHP5. For more information, please follow other related articles on the PHP Chinese website!