Ok I will admit I suck at making regex patterns. I want to transform the value to be all lowercase, _ instead of spaces, and no special chars. (Basically a websafe filename). Here is what I have. It works all except stripping out special chars. Any help would be great. v = v.toLowerCase(); v = v.gsub('' '', ''_''); v = v.gsub(''/[^a-z0-9\s]/i'', ''''); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
v = v.gsub(/[^a-z0-9\s]/i, ''''); On Jun 12, 5:12 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Ok I will admit I suck at making regex patterns. > > I want to transform the value to be all lowercase, _ instead of > spaces, and no special chars. (Basically a websafe filename). Here is > what I have. It works all except stripping out special chars. > > Any help would be great. > > v = v.toLowerCase(); > v = v.gsub('' '', ''_''); > v = v.gsub(''/[^a-z0-9\s]/i'', '''');--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
v = v.gsub(/[^a-z0-9\s]/i, ''''); On Jun 12, 5:12 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Ok I will admit I suck at making regex patterns. > > I want to transform the value to be all lowercase, _ instead of > spaces, and no special chars. (Basically a websafe filename). Here is > what I have. It works all except stripping out special chars. > > Any help would be great. > > v = v.toLowerCase(); > v = v.gsub('' '', ''_''); > v = v.gsub(''/[^a-z0-9\s]/i'', '''');--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks! On Jun 12, 5:30 pm, blechler <lech...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> v = v.gsub(/[^a-z0-9\s]/i, ''''); > > On Jun 12, 5:12 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Ok I will admit I suck at making regex patterns. > > > I want to transform the value to be all lowercase, _ instead of > > spaces, and no special chars. (Basically a websafe filename). Here is > > what I have. It works all except stripping out special chars. > > > Any help would be great. > > > v = v.toLowerCase(); > > v = v.gsub('' '', ''_''); > > v = v.gsub(''/[^a-z0-9\s]/i'', '''');--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---