On Thu, 19 Jan 2006, Eric Luo wrote:

> In your solution:
>
>  <SNPB>  <foo SNPB>  <SNPB bar>  <foo SNPB bar> 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 "
   => 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