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.
Why not just use if(string.toUpperCase() == string)? ._. Its more "elegant"...
I think you're trying to force in RegExp, but as someone else stated, I don't think this is the best use of regexp...
Simplest would seem to be:
^[^a-z]*$
How about (s == uppercase(s))
--> string is all caps?
The string contains a lowercase letter if the expression /[a-z]/
returns true, so simply perform this check, if it's false you have no lowercase letters.
That sounds like you want: ^[^a-z]*$
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.)