Well, Hassan makes a good point that this will eat any non-ascii characters. Consider whether you want to do that. If you don't, you'll likely have to url-encode the result (I don't think e.g., accented characters are usable in URLs, are they?
-----Original Message----- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Ben Knight Sent: Thursday, October 02, 2008 11:48 AM To: rubyonrails-talk@googlegroups.com Subject: [Rails] Re: Removing Non Alpha & Numeric Characters From String Roy Pardee wrote: > This is arguably a tad bit prettier: > > title.downcase.gsub(/[^a-z ]/, '').gsub(/ /, '-') > > Not sure if it's that much better... That works great (and looks prettier :-)! Thanks. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---