PHP regular matching Chinese

Time:2020-10-30

PHP regular matching Chinese

@author: CooperZhang

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

matters needing attention:

  • At the end of the regular expression, u should be added/^...$/u

1、 All matches are in Chinese

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

2、 Match contains Chinese

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

3、 Match Chinese and English (including symbols)_)

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

This work adoptsCC agreementThe author and the link to this article must be indicated in the reprint

Recommended Today

Cartoon, programmer and product manager

Internet crime series Internet crimes series – Preface On the first day of work, the front-end sued the county government and listed five crimes This cartoon isInternet crime series#2」 This is about the last time Wang Da Na sued the back end, the company’s product managers made various kinds of demons, abuse and exploitation, which […]