Created
March 18, 2014 12:13
-
-
Save andrienko/9618893 to your computer and use it in GitHub Desktop.
sanitize string to look more like identifier. Numberless.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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