O
O
Orbite2017-11-28 09:21:42
Perl
Orbite, 2017-11-28 09:21:42

How to check if a string is uppercase?

How to check if all characters of a string are in upper case?
if($str = all uppercase characters){
action
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
pcdesign, 2017-11-28
@pcdesign

if ($str =~ /^[ \p{Uppercase}]+$/) {
    print "ВСЕ БУКВЫ БОЛЬШИЕ r\n";
}

L
Leonid Nikolaev, 2017-11-28
@nikonor

if ( $str =~ /^[A-ZA-Z]+$/ )
this is, of course, if the locale is enabled and all that.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question