in reply to mysteries of regex substring matching

For completeness:

Another workaround was so trivial that I skipped it in my previous answer

You can build regexes from smaller ones with string interpolation

DB<73> p $capt4 = '(....)' x 4 (....)(....)(....)(....) DB<74> x $x =~ m/ $capt4 (.+) /x 0 'AAD3' 1 4017 2 8372 3 '01D9' 4 '8AAED18778DEF993' DB<75>

I think that's the most readable solution.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: mysteries of regex substring matching
by LanX (Saint) on Jan 16, 2021 at 00:49 UTC
    Same approach, but as a one liner:

    DB<5> p 0123456789012345678901234567890123456789 DB<5> x / @{[ '(....)' x4 ]} (.+) /x 0 0123 1 4567 2 8901 3 2345 4 678901234567890123456789 DB<6>

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery