Created
September 24, 2009 19:39
-
-
Save robertsosinski/192975 to your computer and use it in GitHub Desktop.
RegEx scrubber to make permalinks from strings
This file contains hidden or 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
name.downcase.gsub(/'/, "").gsub(/[^[:alnum:]]/, "_").gsub(/_{2,}/, "_").gsub(/^_|_$/, "") | |
# scrub out: ^contractions ^non-alpha-num characters ^extra underscores ^other underscores |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment