« Return to Thread: escaping special characters.

Re: escaping special characters.

by Colin Law-4 :: Rate this Message:

Reply to Author | View in Thread


2009/7/9 Santosh Turamari <rails-mailing-list@...>:

>
> Hi,
>
>  I have to remove the speial symbols from list of names. But I want to
> remain the dot(.) in the name itself.
> I use ommunity_org_review.name.downcase.strip.squeeze("
> ").gsub(/['^''&''!']/,
> '-').squeeze("-").chomp("-")
> or
> org_review.company.downcase.strip.squeeze("
> ").gsub(/[^[:alnum:]]/,'-').squeeze("-").chomp("-")
>
> It is sibstituting with hyphen(-), including dot(.) also. I want to
> remain dot. How to do it. please help.
>

I would suggest building up the expression a bit at a time and making
sure you understand what the result at each stage is and why.  You
should them be able to work out what is going wrong.  Then if you
cannot get a particular operation to work as you expect and do not
understand how to fix it ask for help on that particular bit.

Colin

Colin

--~--~---------~--~----~------------~-------~--~----~
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@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

 « Return to Thread: escaping special characters.