QM has asked for the wisdom of the Perl Monks concerning the following question:
Is it possible to have a capture for the purposes of backreferences, but not returned as part of the match?
# Example @x = 'bogus firstblahjokeblahthird bogus' =~ /(first)(?:blah).*?\2(thi +rd)/; # doesn't work # @x is empty
(In fact, I suspect the above doesn't work because, while there is eventually a 2nd capture group, it hasn't captured anything before the backreference. But that isn't really the point here.)
I don't really have a specific need, but it just seems interesting to say "this capture is only for backreference, and not for returning as a capture".
-QM
--
Quantum Mechanics: The dreams stuff is made of
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Regex backreference without capture
by rsFalse (Chaplain) on Mar 01, 2019 at 15:52 UTC | |
by QM (Parson) on Mar 05, 2019 at 10:31 UTC | |
Re: Regex backreference without capture (?&NAME) NamedCapture
by beech (Parson) on Mar 05, 2019 at 03:36 UTC | |
by QM (Parson) on Mar 05, 2019 at 10:33 UTC | |
by rsFalse (Chaplain) on Mar 05, 2019 at 12:34 UTC |
Back to
Seekers of Perl Wisdom