From: Trish Ball Date: 2007-01-04T00:19:10+09:00 Subject: Re: Problems with Sting#sub and regular expressions ------=_Part_128525_19654923.1167837547781 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I did change my expression to read: irb(main):001:0> " ' Helen".sub(/^(['\s]*)/, "") => "Helen" and that works on the first try... but I was just wondering why the previous example does not work. Thanks, Trish On 1/3/07, Trish Ball wrote: > > 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_128525_19654923.1167837547781--