# Escaping special characters

**URL:** <https://www.ruby-forum.com/t/escaping-special-characters/171797>\
**Category:** Rails\
**Created:** [July 9, 2009, 12:19pm UTC](https://www.ruby-forum.com/t/escaping-special-characters/171797 "2009-07-09T12:19:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![santoshturamari](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@santoshturamari](https://www.ruby-forum.com/u/santoshturamari)\
**Post date:** [July 9, 2009, 12:19pm UTC](https://www.ruby-forum.com/t/escaping-special-characters/171797/1 "2009-07-09T12:19:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![santoshturamari](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@santoshturamari](https://www.ruby-forum.com/u/santoshturamari)\
**Post date:** [July 9, 2009, 9:07pm UTC](https://www.ruby-forum.com/t/escaping-special-characters/171797/2 "2009-07-09T21:07:00Z")

</div>

2009/7/9 Santosh T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> “).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
