From: "David A. Black" Date: 2007-03-18T21:01:46+09:00 Subject: Re: Another RegExp question Hi -- On 3/18/07, J. mp wrote: > Hi again, I'm allways here to ask how to use regular expressions. > what I want now is to replace chars from a string with empty spaces > > sample = "thi's is a tes<>%$#!|t" > > what I want is use sample.sub(\['<>%$#!|]\,"") > and the outcome shoudl be > > "this is a test" > > But I only can replace the first occurence of the chars specified in the > reg exp > > How can I replace all occurences? Use gsub instead of sub. David -- Q. What is THE Ruby book for Rails developers? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.com)