Link to home
Start Free TrialLog in
Avatar of Karina051699
Karina051699

asked on

if ALL CAPITAL LETTER.....

What would be best to convert the following names (just those with ALL CAPITAL LETTERS)
LONGNAME to Longname
LONG NAME to Long Name
NAME (no conversion)
Long Name (no conversion)


if((length($NAME) > 6) && ALL CAPITAL LETTER???) {
ASKER CERTIFIED SOLUTION
Avatar of Kim Ryan
Kim Ryan
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Karina051699
Karina051699

ASKER

Thanks,

Thats the first part of the solution. But how to dtermine the input is lower or uppercase?
if the user wants his name all lower case, it should not change it. Just, if the name
is longer than 6 and all capitals it should convert it with your provided code.
(space problems in a little frame)
OK, I think I understand now. Try

# $NAME more than 6 chars, all capitals
if( length($NAME) > 6 and $NAME =~ /[A-Z/ ) {...}




That's it!

Thanks, teraplane
Avatar of ozo
length($NAME) > 6 and $NAME !~ /[a-z]/
I used ozo's line because it wont convert correct names like

My Name

or Myname

(just ALL CAPITALS like MY NAME or MYNAME ...)

Thanks Ozo