in reply to Re^2: Zero-width look-ahead regexp question
in thread Zero-width look-ahead regexp question
The word boundary does not help, because for instance 'FOOBAR X' and 'FOOBARX' are both strings which should be accepted (because both BAR X and BARX are considered different from <BAR>), while 'FOOBAR' should be rejected.
Actually I meanwhile believe to having found a solution to my problem while having lunch (it is surprising how a glass of Italian Chardonnay can do good to the brain cells):
so unless someone can find a flaw with this (the examples where I tried it, worked so far), I think I will stick with it. It is not a beautiful solution, though, because if I would like one day to pick up what is to the right of FOO, I can't do it. So I'm still interested in hearing alternative proposals.$name =~ /^FOO(?!(BAR|BAZ)$)/
Maybe just to make it clear, here are concrete examples: The following strings should be accepted:
while the following should be rejected:FOOABC FOO_BAR FOOBA FOOBAZZZZ FOOBAR BAZ
FOOBAR FOOBAZ BARBAZ
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Zero-width look-ahead regexp question
by ww (Archbishop) on Jul 02, 2008 at 03:25 UTC | |
by rovf (Priest) on Jul 02, 2008 at 07:02 UTC |