From: Katarina WONG Date: 2005-06-30T03:05:16+09:00 Subject: Re: regex and gsub quest On Wed, 29 Jun 2005 16:12:13 +0200, Kent Sibilev wrote: >> Why doesn't the code below work : (other than an incorrect regex for >> comma) >> >> a = ["hi,there", "jot this note down", "may i,use the, car"] >> a.each do |x| x.gsub(/\,/ , " ") end >> As well as using gsub! to see any result in your case, you should not prepend the comma with a backslash, the comma has no special meaning. Last, never play with regexes without irb and your favorite ShowRE ! def showRE(a,re) if a =~ re res = "#{$`}<<#{$&}>>#{$'}\n" res += "1: #$1\n" res += "2: #$2\n" res += "3: #$3\n" res += "4: #$4\n" res += "5: #$5\n" res += "6: #$6\n" res += "7: #$7\n" res += "8: #$8\n" res += "9: #$9\n" else "no match" end end puts showRE( "hi,there", /,/ ) -- Katarina