I don't have a good idea of your difficulties, but here's a generalized approach. I can't provide a working example at the moment, so the following is untested handwaving.
The (*SKIP)(*FAIL) variable-width negative look-back hack works by messing up a match of something you need to have for an overall match. For a large regex, I tend to take the approach of factoring regex elements:
# stuff we want to capture my $capture_this = qr{ ... }xms; my $capture_too = qr{ ... }xms; my $capture_also = qr{ ... }xms; my $capture_more = qr{ ... }xms; # stuff we want to cause match failure if before certain other stuff my $avoid_this = qr{ ... }xms; my $avoid_too = qr{ ... }xms; my $avoid_also = qr{ ... }xms; my $negatory = qr{ (?> [aeiou]+ | f[eio]e? | $avoid_too) }xms; # stuff we need for an overall match, may or may not be captured my $needed_for_match = qr{ ... }xms; my $needed_too = qr{ ... }xms; my $string = get_stringy_stuff(); my ($this, $too, $also, $yet_another) = $string =~ m{ \A ($capture_this) ($capture_too) ... (?> (?> $avoid_this | $avoid_too | $avoid_also | etc) $needed_for_ +match (*SKIP)(*F))? $needed_for_match # needed for overall match ($capture_also) ... (?> $negatory $needed_too (*SKIP)(*FAIL))? ($needed_too) # needed for overall match, also captured \z }xms; do_something_with($this, $too, $also, $yet_another);
Give a man a fish: <%-(-(-(-<
In reply to Re^3: Another Look behind
by AnomalousMonk
in thread Another Look behind
by dominic01
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |