Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class String
- def sanitize
- s = self.to_s
- s.gsub!(/\W+/, ' ') # all non-word chars to spaces
- s.strip! # ohh la la
- s.downcase! #
- s.gsub!(/\ +/, '-') # spaces to dashes, preferred separator char everywhere
- s
- end
- end
Add Comment
Please, Sign In to add comment