From: Anselm Heaton Date: 2006-06-29T02:15:11+09:00 Subject: Re: remove all illegal chars form string On Wednesday 28 June 2006 14:09, thomas coopman wrote: > 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" "exam@p Le3|�".gsub(/\W/, '') will return "exampLe3" I strongly suggest you learn about regular expressions. You can start here, http://en.wikipedia.org/wiki/Regular_expression , there are many links to many tutorials. Here, http://www.rubycentral.com/book/tut_stdtypes.html , you can find info on ruby regular expressions ; though it might be best to get yourself a Ruby book. Anselm -- ------------------------------ Netuxo Ltd a workers' co-operative providing low-cost IT solutions for peace, environmental and social justice groups and the radical NGO sector ------------------------------