Tip: Click lines to highlight, hold ctrl/cmd to multi-select
CamelCase (22-Nov @ 21:44)
Syntax Highlighted Code
- String.prototype.toCamelCase = function() {
- return this.toString()
- .replace(/([A-Z]+)/g, function(m,l){
- return l.substr(0,1).toUpperCase() + l.toLowerCase().substr(1,l.length);
- })
- .replace(/[-_s](.)/g, function(m, l){
- return l.toUpperCase();
- });
- };
Plain Code
String.prototype.toCamelCase = function() {
return this.toString()
.replace(/([A-Z]+)/g, function(m,l){
return l.substr(0,1).toUpperCase() + l.toLowerCase().substr(1,l.length);
})
.replace(/[-_s](.)/g, function(m, l){
return l.toUpperCase();
});
};