Determine if string is all caps with regular expression

前端 未结 9 877
轻奢々
轻奢々 2020-12-30 00:46

How can you determine if a string is all caps with a regular expression. It can include punctuation and numbers, just no lower case letters.

9条回答
  •  隐瞒了意图╮
    2020-12-30 01:11

    m/^[^a-z]*$/
    

    For non-English characters,

    m/^\P{Ll}*$/
    

    (\P{Ll} is the same as [^\p{Ll}], which accepts all characters except the ones marked as lower-case.)

提交回复
热议问题