From: Trish Ball Date: 2007-01-04T00:14:04+09:00 Subject: Problems with Sting#sub and regular expressions ------=_Part_128441_13560740.1167837241446 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I have been working on an expression using String#sub and am getting inaccurate results on the first time I run the expression, but not on the following times I run it. Is there something wrong with my regular expression? The intent of my regular expression is to remove preceding spaces and apostrophes. irb(main):001:0> " ' Helen".sub(/^(['\s]*)(.*)/, "#{$2}") => "" irb(main):002:0> " ' Helen".sub(/^(['\s]*)(.*)/, "#{$2}") => "Helen ------=_Part_128441_13560740.1167837241446--