Home  >  Article  >  Backend Development  >  Solution to the 'Rule Error' prompt when there is '|' in regular verification in ThinkPHP5

Solution to the 'Rule Error' prompt when there is '|' in regular verification in ThinkPHP5

黄舟
黄舟Original
2018-05-16 17:14:461882browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What is MVC frameworkNext article:What is MVC framework