in reply to Match a pattern only if it is not within another pattern

Here's my aborted attempt at trying to get this to work with parse::recdescent. Currently it doesn't work but maybe someone can supply this missing ingredients. I've got to go back to work ;)

The RecDescent FAQ may be of help for anyone that wants to tinker with this.

#patternInAnotherPattern.pl use strict; use warnings; use Test::More qw(no_plan); use Parse::RecDescent; my $str = 'blfoo and barthisfoothatqux and barsofooquxhim andfoosom fo +o'; my $expected = 'bl123 and barthisfoothatqux and barsofooquxhim and123s +om 123'; my $parse = Parse::RecDescent->new(q( document: chunk(s) /\Z/ { $return = join ('', @{$item[1]}) } chunk: /./ #just a placeholder, to get the grammar to return somethin +g, anything! filler_chunk: /(?!(foo|bar|qux).)*/ #inch ahead combi_chunk: boundary_chunk foo_chunk boundary_chunk boundary_chunk: /(bar|qux)((?!foo).)*/ #inch ahead foo_chunk: /foo/ bar_chunk: /bar/ qux_chunk: /qux/ )); my $res = $parse->document($str); is($res,$expected);