in reply to Re^5: Regex: return the pattern instead of the actual match
in thread Regex: return the pattern instead of the actual match
and checking which of $1 or $2 is defined./(foo\d+)|(bar\S+?)/
It requires some out-of-bound data that maps to capture group identifier to sub-pattern, and this out-of-bound data needs to be set up when creating the pattern (you can't use this trick if the pattern is given, unless you deconstruct and reconstruct the pattern).
And then, instead of using captures, one may use marks:
and consult $REGMARK afterwards./foo\d+(*:foo)|bar\S+(*:bar)/
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Regex: return the pattern instead of the actual match
by LanX (Saint) on Sep 17, 2011 at 12:17 UTC |