From: Wes Gamble Date: 2006-03-29T03:43:51+09:00 Subject: Re: Regexp to match strings that _don't_ being with a string In my example, won't /^(?!xyz)/ also match 29384723xyz02342 which is a little more than I want? WG Andrew Johnson wrote: > On Wed, 29 Mar 2006 03:24:36 +0900, Wes Gamble wrote: > >> I tried /^[^(xyz)]/ but I don't trust it. I don't think the grouping >> will take inside the character class. > > The [^(xyz)] creates a negative character class, so your regex would > match any string that started with a character not in the given set. > Not what you really want > >> Do I need a negative lookahead assertion? > > That would be a simple solution: /^(?!xyz)/ which will match when > the beginning of the line/string is not followed by 'xyz'. > > andrew -- Posted via http://www.ruby-forum.com/.