Home >Backend Development >PHP Tutorial >About PHP regular matching Chinese

About PHP regular matching Chinese

PHPz
PHPzforward
2020-09-25 11:22:595379browse

About PHP regular matching Chinese

Recommendation: "PHP Video Tutorial"

PHP regular matching Chinese

@author: CooperZhang

Regular matching character set [{4e00}-\x{9fa5}]

Note:

  • U should be added at the end of the regular expression, in the form: /^...$/u

1. The match contains all Chinese

/^[{4e00}-\x{9fa5}]+$/u

2. The match contains Chinese

/[{4e00}-\x{9fa5}]+/u

3. Match Chinese and English (including symbols _)

/[\w{4e00}-\x{9fa5}]+/u

The above is the detailed content of About PHP regular matching Chinese. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:learnku.com. If there is any infringement, please contact admin@php.cn delete