Return to Snippet

Revision: 2369
at February 4, 2007 15:51 by vanne


Updated Code
#substitute string_name for your variable or a string
#substitute "-" for your choice of character
#note: doesn't recognize accented characters properly
string_name.gsub(/[^a-z0-9]+/i, '-')

Revision: 2368
at February 4, 2007 15:50 by vanne


Initial Code
#substitute string_name for your variable or a string
#substitute "-" for your choice of character
string_name.gsub(/[^a-z0-9]+/i, '-')

Initial URL

                                

Initial Description
Use this to sanitize a string and convert all wierd characters to your choice of delimiter

Initial Title
Sanitize String

Initial Tags
regex, rails, ruby

Initial Language
Ruby