Strip all but [a-zA-Z] - Node.js String

Node.js examples for String:Replace

Description

Strip all but [a-zA-Z]

Demo Code


'use strict';/*w ww .j  a v a 2 s  .c  o  m*/

String.prototype.camelize = function () {
  return this.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function (match, index) {
    if (+match === 0) {
      return '';
    }// or if (/\s+/.test(match)) for white spaces
    return index === 0 ? match.toLowerCase() : match.toUpperCase();
  });
};

Related Tutorials