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

MVC and Vue

MVC and Vue This article was written on July 27, 2020 The first question is: is Vue an MVC or an MVVM framework? Wikipedia tells us: MVVM is a variant of PM, and PM is a variant of MVC. So to a certain extent, whether Vue is MVC or MVVM or not, its ideological direction […]