From: Wes Gamble Date: 2006-03-29T04:30:26+09:00 Subject: Re: Regexp to match strings that _don't_ being with a string Andrew, That works fine. In actuality, I do need the ability to pass one regex to do the job into another utility that will use it to operate on an array of strings. So although !~ is cool, I really didn't want to have to iterate through the strings myself. Thanks, Wes Andrew Johnson wrote: > On Wed, 29 Mar 2006 03:43:51 +0900, Wes Gamble wrote: >> In my example, won't /^(?!xyz)/ also match >> >> 29384723xyz02342 >> >> which is a little more than I want? > > Uhm, maybe I've misunderstood (wouldn't be the first time) -- I thought > you > wanted to match strings that did not begin with 'xyz' ... and as far as > I > can tell, "29384723xyz02342" does not start with 'xyz'. > > while DATA.gets > print if ~/^(?!xyz)/ > end > __END__ > xyefoo > xyzpfoo > asdfsdf > 1230xyzasdf > > produces: > > xyefoo > asdfsdf > 1230xyzasdf > > > puzzled, > andrew -- Posted via http://www.ruby-forum.com/.