string = 'john, tony'
newTerms = string.gsub(/\W/, "")
thanks
--
Posted via http://www.ruby-forum.com/.
>
> I'm trying to replace all characters that are not letters numbers and
> white spaces in a string. I'm getting the characters eliminated in
> this
> case a comma but the white space is eliminated to. How do I get around
> that?
>
>
> string = 'john, tony'
> newTerms = string.gsub(/\W/, "")
> newTerms = string.gsub(/[^\w\s]/, "")
=> "john tony"
is one way...
>>
>> string = 'john, tony'
>> newTerms = string.gsub(/\W/, "")
>
> > newTerms = string.gsub(/[^\w\s]/, "")
> => "john tony"
>
> is one way...
thanks a million