Proper Case
function Proper_Case (s)
{
var Tokenize = function (t) {
var first = 0;
var last = t.length;
var arr = new Array()
var re = new RegExp("[\r\n\t ]+", "g");
for (var x=re.exec(t); x; x=re.exec(t)) {
last = x.index;
arr.push(t.substring(first, last));
first = re.lastIndex;
}
if (first < t.length) {
arr.push(t.substring(first, t.length));
}
return arr;
}
var Proper_Case_One = function (word) {
var car = word.substr(0,1); // Think Lisp!
var cdr = word.substr(1); // More Lisp!
return car.toUpperCase() + cdr.toLowerCase();
}
var output = new String();
var tokens = Tokenize(s); // split string into parts...
for (var ix=0; ix < tokens.length; ix++) {
if (0 < ix) { output += ' '; }
output += Proper_Case_One (tokens[ix]);
}
return output;
}