TapTapTaperoo has asked for the wisdom of the Perl Monks concerning the following question:
my $string = XXXXXXXXXABXXXXXXX
m/(A|B)(A|B)/
for matching AA, AB, BA, BB
I want to keep these matches in the context of the larger string, while still being able to distinguish matches. Is there a way to substitute and return the successful event ie:
XXXXXXXXXXXabXXXXXXXXX
When I try to substitute it returns indistinguishable for the original hit ie:
XXXXXXXXXX(A|B)(A|B)XXXXXXXXX
Thank you!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex Pipe Return
by roboticus (Chancellor) on Dec 27, 2012 at 01:24 UTC | |
|
Re: Regex Pipe Return
by graff (Chancellor) on Dec 27, 2012 at 01:41 UTC | |
|
Re: Regex Pipe Return
by LanX (Saint) on Dec 27, 2012 at 01:34 UTC | |
|
Re: Regex Pipe Return
by BrowserUk (Patriarch) on Dec 27, 2012 at 02:12 UTC | |
|
Re: Regex Pipe Return
by BillKSmith (Monsignor) on Dec 27, 2012 at 03:00 UTC |