Tip: Click lines to highlight, hold ctrl/cmd to multi-select

CamelCase (22-Nov @ 21:44)

remy

Syntax Highlighted Code

  1. String.prototype.toCamelCase = function() {
  2.   return this.toString()
  3.     .replace(/([A-Z]+)/g, function(m,l){
  4.       return l.substr(0,1).toUpperCase() + l.toLowerCase().substr(1,l.length);
  5.     })
  6.     .replace(/[-_s](.)/g, function(m, l){
  7.       return l.toUpperCase();
  8.     });
  9. };

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();
    });
};

Codedump Run

Permalink: http://codedumper.com/camelcase