ruby - Make space to dash with regexp -
I've got a Sinatra app where I'm planning to make a Fried-url when I fly. I have found a regexp function which looks like this, but it will not change 'empty space' from 'dash', '' to '-'.
def self.make_slug (title) title.downcase.gsub (/ /, '-'). Gsub (/ [^ a-z0- 9 _] /, ''). Squeeze ('-') termination
Thanks in advance!
Update
Now I am trying to change to o in another o, my code looks like this but won 'work' any idea?
gsub (/ [åä] /, 'a') gsub (/ [ö] /, 'o')
a-Z0-9 _
(Thus, "-") "". Include in the list like [^ a-z0- 9 _-]
Comments
Post a Comment