Skip to content

Instantly share code, notes, and snippets.

@andrienko
Created March 18, 2014 12:13
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save andrienko/9618893 to your computer and use it in GitHub Desktop.
sanitize string to look more like identifier. Numberless.
String.prototype.sanitize = function(){
return this.replace(/[^a-zA-Z]/g,'_').replace(/_{2,}/g,'_').toLowerCase().replace(/^_+|_+$/g,'');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment