views:

33

answers:

1

Hi,

i've come across the problem. I can't understand how to check if Character is in lowercase in as3. can someone advice?

+4  A: 

You could check if its character code is within the lowercase range.

Even simpler (and less efficient) would be something like myChar == myChar.toLowerCase()

thenduks
+1 For your second method. The first one is flawed for anything non-ASCII, though. And I'm not even sure it's more "efficient". To get the codepoint, you'd have to call a method anyway (charCodeAt(0)). And then you will check for a range. toLowerCase is most likely implemented as a lookup and it's native code, so it shouldn't be much slower. But more importantly, it has more chances of being correct. (Note there's a toLocaleLowerCase which would be a better option in theory, but the docs say it's currently unimplemented as intended; i.e. currently, it's like calling toLowerCase).
Juan Pablo Califano
myChar == myChar.toLowerCase() is great. I used it, and it worked
Oleg Tarasenko
@Juan: True, thanks.
thenduks