Created 03/2002

camelCase <-> selector-case in JavaScript w/o Regex

Scott Andrew pointed to Tim Morgan's camelCase <-> selector-case functions. Screaming Jedi cool. But they use JavaScript regular expressions. JavaScript regular expressions I've never gotten cozy with. Perhaps I should seek counseling. Love the Regular Expressions in PHP and Cold Fusion though.

Anyway, here are some alternative functions, and a demonstration too. More on camelCase.


Share and enjoy.

function noRegexToCamel(str) { // converts to camelCase
  var outstr = str[0];
return outstr;

Try it! Enter something in selector-case below:

function noRegexToSel(str) { // converts to selector-case
  var outstr="";
return outstr;

Try it! Enter something in camelCase below: