--1892976104-77918965-11515068190679 Content-Type: MULTIPART/MIXED; BOUNDARY="1892976104-77918965-1151506819=:20679" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1892976104-77918965-11515068190679 Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Content-ID: <Pine.LNX.4.64.0606281500261.20679 / ushgarak.icemark.net> > 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'sossible with sub or gsub. My first Idea was to loop over the string and check every character but I wondered if there is something more simple or better. str="exam@p L_e3|þÁ¥¹" puts str.gsub(/[^a-zA-Z0-9]/, "") # yields: # exampLe3 a bit shorter would be puts str.gsub(/\W/, "") # but "word"-characters (\w) and "non-word"-characters (\W) also # contain the' _', so this would yield: # exampL_e3 Benedikt ALLIANCE, n. In international politics, the union of two thieves who have their hands so deeply inserted in each other's pockets that they cannot separately plunder a third. (Ambrose Bierce, The Devil's Dictionary) --1892976104-77918965-11515068190679-- --1892976104-77918965-11515068190679--