> -----Original Message-----
> From: thomas coopman [mailto:thomas.coopman / gmail.com] 
> Sent: Wednesday, June 28, 2006 8:10 PM
> To: ruby-talk ML
> Subject: remove all illegal chars form string
> 
> Hi,
> 
> Is there a simple way to remove all but the legal chars from 
> a string.  where the legal chars are for example: a-z A-Z 0-9
> So everything should be removed from the string but these characters.
> "exam@p  Le3| --> "exampLe"
> 
> I don't know very much about regular expressions, so I don't 
> know if it's possible with sub or gsub.

Character sets with ranges: [a-z]
Negated sets: [^a-z]

"exam@p  Le3|.gsub(/[^a-zA-Z0-9]/,'') => "exampLe3"

ben