in reply to RegEx - match !foo followed by foo
That's your classic "inchworm" pattern, so it's not the fastest in the world.if (/^(foobar:((?!=gonk|\@).)+)/) { print "matched $1\n"; }
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
And the spec is still broken:
I'm having problems working out how to perform the following regex. I want to match foobar:Xgonk where X is between 1 and 5 characters, and can be anything except 'gonk' (or the beginning of 'gonk') or '@'. I then want to remove gonk or @.The last "or @" is spurious. There could never be an "@" there, since it has to have a trailing "gonk" where we stop.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: RegEx - match !foo followed by foo
by Melly (Chaplain) on Mar 16, 2006 at 15:24 UTC | |
by kwaping (Priest) on Mar 16, 2006 at 15:29 UTC | |
|
Re^2: RegEx - match !foo followed by foo
by Melly (Chaplain) on Mar 16, 2006 at 13:38 UTC |