in reply to Re: Match a pattern only if it is not within another pattern
in thread Match a pattern only if it is not within another pattern
I'm trying to solve the more "general" problem with parse::recdescent, further on in the thread. I gave up before finding a solution though.use strict; use warnings; use Test::More qw(no_plan); my $str = 'blfoo and barthisfoothatqux and barsofooquxhim andfoosom fo +o'; my $expected = 'bl123 and barthisfoothatqux and barsofooquxhim and123s +om 123'; $str =~ s[(bar.+?qux)|(foo)][defined $2 ? '123' : $1]xge; is($str,$expected); #switch qux and bar $str = 'blfoo and quxthisfoothatbar and barsofooquxhim andfoosom foo'; $expected = 'bl123 and barthisfoothatqux and barsofooquxhim and123som +123'; $str =~ s[(bar.+?qux)|(foo)][defined $2 ? '123' : $1]xge; is($str,$expected);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Match a pattern only if it is not within another pattern
by xdg (Monsignor) on Aug 17, 2005 at 13:33 UTC | |
|
Re^3: Match a pattern only if it is not within another pattern
by BrowserUk (Patriarch) on Aug 17, 2005 at 17:26 UTC | |
by Transient (Hermit) on Aug 17, 2005 at 17:31 UTC | |
by BrowserUk (Patriarch) on Aug 17, 2005 at 17:40 UTC | |
by Transient (Hermit) on Aug 17, 2005 at 17:50 UTC |