in reply to Re: RegEx - match pattern not followed by literal
in thread RegEx - match pattern not followed by literal
$users_regexp = qr/^./s; 'abc,v' = /$users_regex(?!,v$)/; # Matches, but it shouldn't. $users_regexp = qr/^.*$/s; 'abc,v' = /$users_regex(?!,v$)/; # Matches, but it shouldn't. $users_regexp = qr/,/; 'abc,v' = /$users_regex(?!,v$)/; # Matches, but it shouldn't.
Solution:
which simplifies to/^(?=.*?$users_regex)(?!.*?,v$)/s
/^(?!.*,v$).*?$users_regex/s
Of course, this is not nearly as readable as the original.
Updated to show more examples where the parent doesn't work.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: RegEx - match pattern not followed by literal
by Melly (Chaplain) on Oct 12, 2006 at 15:53 UTC | |
by ikegami (Patriarch) on Oct 12, 2006 at 15:57 UTC | |
by driver8 (Scribe) on Oct 13, 2006 at 07:00 UTC |