From: Eric Luo Date: 2006-01-20T11:09:37+09:00 Subject: Re: Question about regular expression ------=_Part_217_18789833.1137722964119 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sorry for my mistake. I do want to let "STR bla SNPB" matched. but I said it mistakenly in the opposite in my lastest post. I want that the appearance of the word rather string STR just before a SNPB will cause the match to fail. That is, "STR bla SNPB", "PreSTR SNPB" "STRSNPB" will be matched. but "STR SNPB" will not. 2006/1/20, ara.t.howard@noaa.gov : > > On Thu, 19 Jan 2006, Eric Luo wrote: > > > In your solution: > > > > matched. > > > > But "STR bla SNPB " will also be matched, which is not expected. > > it should not: > > irb(main):002:0> %r/^ (?: (?:[^S]) | (?:S[^T]) | (?:ST[^R]) )* SNPB > /ox.match "STR bla SNPB " > =3D> nil > > and does not on any of my machines. are you seeing something different? > > > > the way that regular expression reads is: > > - beginning of line > > - zero or more things that are either > - not an S > - an S followed by not a T > - or ST followed by not an R > > - the string SNPB > > (we ignore the remainder of the string, though you could do more here > if > needed) > > so the appearance of the string STR __anywhere__ before a SNPB will cause > the > match to fail. > > hth. > > -a > -- > strong and healthy, who thinks of sickness until it strikes like > lightning? > preoccupied with the world, who thinks of death, until it arrives like > thunder? -- milarepa > > > ------=_Part_217_18789833.1137722964119--