Name: isLowerCase(), isUpperCase() (for single letter) - determines if letter is uppercase or lowercase
Author: senocular: www.senocular.com
Date: 1899-12-31T00:08:15.600
Documentation:
String ISLOWERCASE and ISUPPERCASE: determines
if a letter is a lowercase letter or an uppercase letter.
Arguments
- pos: (optional) position of the letter in the string to be checked for uppercase
or lowercase. If position is greater than the length of the string, false
is returned. Default is 0 (the first character in the string).
Example:
phrase = "Hello THERE";
trace(phrase.isUpperCase()); // tests for "H" returns true
trace(phrase.isLowerCase(4)); // tests for "o" returns true
trace(phrase.isLowerCase(phrase.length-1)); // tests for "E" returns false
1
2
3
4
5
6
7
8
9
10
11
12
String.prototype.isLowerCase = function(pos){
if (!arguments.length) var pos = 0;
if (pos >= this.length) return false;
var c = this.charCodeAt(pos);
return (c > 96 && c < 123);
}
String.prototype.isUpperCase = function(pos){
if (!arguments.length) var pos = 0;
if (pos >= this.length) return false;
var c = this.charCodeAt(pos);
return (c > 64 && c < 91);
}