Here you can find the source of unCamelCase()
/**/*from w w w .j a va 2 s .com*/ * Turns someCrazyName into Some Crazy Name * Decent job of acroynyms: * ABCAcryonym => ABC Acryoynm * xmlHTTPRequest => Xml HTTP Request */ String.prototype.unCamelCase = function(){ return this // insert a space between lower & upper .replace(/([a-z])([A-Z])/g, '$1 $2') // space before last upper in a sequence followed by lower .replace(/\b([A-Z]+)([A-Z])([a-z])/, '$1 $2$3') // uppercase the first character .replace(/^./, function(str){ return str.toUpperCase(); }) } // Or, one liner. // String.prototype.unCamelCase=function(){return this.replace(/([a-z])([A-Z])/g,'$1 $2').replace(/\b([A-Z]+)([A-Z])([a-z])/,'$1 $2$3').replace(/^./,function(s){return s.toUpperCase();})}
String.prototype.toCamelCase = function() { return this.replace(/[- ](\w)/g, function(match) { return match[1].toUpperCase(); });
"use strict"; var toCamelCase = function (string) { if (string.substr(0, 2) !== string.substr(0, 2).toUpperCase()) { return string.substr(0, 1).toLowerCase() + string.substr(1); else { return string; }; ...
String.prototype.toCamelCase = jCube.String.toCamelCase = function () { return this.replace( /-\D|-\d/g, function(s){ return s.charAt(1).toUpperCase()}).replace( /\s\D|\s\d/g, function(s){ return s.charAt(1).toUpperCase()});
String.prototype.toLittleCamelCase = function () { var sourceStr = this.toString(); var str = ''; var strArr = sourceStr.split('-'); strArr.forEach(function (el) { str = str + el.firstUppserCase(); }) str = str.firstLowerCase(); return str; ...
String.prototype.to_camelCase = String.prototype.to_camelCase || function(){ var split = this.split('_').filter(Boolean); var len = split.length; var camelCaseString = ''; for (var i=0;i<len;i++) { if(i===0){ camelCaseString = camelCaseString + split[i].toLowerCase(); else{ ...
String.prototype.underscore_to_camel = function() { return this.replace(/_[a-z]/, function(m){ return m.substring(1).toUpperCase(); }) String.prototype.capitalize = function() { return this.replace(/^[a-z]/, function(m){ return m.toUpperCase(); }) String.prototype.repeat = function(num) { return new Array( num + 1 ).join( this );