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')  
"-" with "" are changing, and then everything changes but with a-Z0-9 _ (Thus, "-") "". Include in the list like [^ a-z0- 9 _-]


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -