使用正则表达式确定字符串是否全部大写 [英] Determine if string is all caps with regular expression
本文介绍了使用正则表达式确定字符串是否全部大写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用正则表达式确定字符串是否全部大写.它可以包含标点符号和数字,但不能包含小写字母.
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.
推荐答案
m/^[^a-z]*$/
对于非英文字符,
m/^\P{Ll}*$/
(\P{Ll}
与 [^\p{Ll}]
相同,它接受除标记为小写的字符之外的所有字符.)
(\P{Ll}
is the same as [^\p{Ll}]
, which accepts all characters except the ones marked as lower-case.)
这篇关于使用正则表达式确定字符串是否全部大写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文