in reply to Re: Regex: return the pattern instead of the actual match
in thread Regex: return the pattern instead of the actual match

Rubbish. The keys of %+ gives you the names of the capture group, the values give you the part of the string that's matched. It doesn't give you the (sub)pattern.
  • Comment on Re^2: Regex: return the pattern instead of the actual match

Replies are listed 'Best First'.
Re^3: Regex: return the pattern instead of the actual match
by LanX (Saint) on Sep 16, 2011 at 08:19 UTC
    Re-Rubbish! It's a very good advice.

    Associating the name of the capture group to the subpattern solves the problem.

    Cheers Rolf

      Really? How does that work? How do you re-construct the subpattern from the (not necessarely unique) label you've given it? And why can't you do the same magical trick with the unique numbered match?
        >Really? How does that work?

        Re: Regex: return the pattern instead of the actual match

        > And why can't you do the same magical trick with the unique numbered match?

        you might need other groupings which are not necessarily interesting.

        The template system I used offers full flexibility. If you wanna do this with numbered matches you need to parse the template.

        Cheers Rolf