Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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