…posted by davidjmedlock:
This originated out of some project I was thinking about doing and I though it’d be useful for others. These functions check to see if a character is upper case or lower case:
function isUpperCase(character) {
if (Asc(character) gte 65 and Asc(character) lte 90) {
return true;
}
else {
return false;
}
}
function isLowerCase(character) {
if (Asc(character) gte 97 and Asc(character) lte 122) {
return true;
}
else {
return false;
}
}
#isUpperCase("A")#
#isLowerCase("A")#
#isUpperCase("a")#
#isLowerCase("a")#
Have fun with it.
This entry was posted
on Tuesday, April 13th, 2004 at 4:47 pm, contains
97 words, and is filed under ColdFusion.
You can follow any responses to this entry through the RSS 2.0 feed.
You can skip to the end and leave a response. Pinging is currently not allowed.
The views and opinions in this blog post are those of its author.
April 13th, 2004 at 4:57 pm
Forgot to add this:
if (Len(character) gt 1) return false;to the top of each of those functions. That way if they pass in a string, it won’t bomb. (It shouldn’t anyway. It should just return whether the first character is upper or lowercase…)
April 14th, 2004 at 1:13 pm
Nice - we might actually use that one. We love CF functions.
Be sure to add it to cflib.org!
Tony
April 14th, 2004 at 1:50 pm
What about a whole string? Here’s my function:
function stringIsUppercase(str) {
if(reFind(”^[A-Z]+$”,arguments.str)) return true;
else return false;
}