How to match uppercase word character with regex in PHP?

前端 未结 2 725
甜味超标
甜味超标 2020-12-21 07:41

I know there is the [A-Z] notation.. but I am not sure if [a-z] is the same as \\w.

I\'d like to match \\w

2条回答
  •  鱼传尺愫
    2020-12-21 08:10

    \w is equivalent of this character class:

    [a-zA-Z0-9_]
    

    If you want upper case unicode characters only then use this character class:

    '/[\p{Lu}\p{N}_]/u'
    

    This will match any one of:

    1. Upper case unicode letter
    2. unicode number
    3. Underscore

提交回复
热议问题