The thing I've mainly used named captures for so far is named access to the capture groups via %+. This can be very useful e.g. in cases like long regexes and/or if you've got one qr// regex inside another qr// regex inside another... keeping track of numbered capture groups quickly becomes impossible.

my $one = qr{ one (?<one> \d+ ) }xi; my $two = qr{ $one two (?<two> \d+ ) }xi; "One9Two8Three7" =~ m{ $two three (?<three> \d+ ) }xi; use Data::Dump; dd \%+; __END__ { # tied Tie::Hash::NamedCapture one => 9, three => 7, two => 8, }

One bigger example that comes to my mind is this one: if you happen to have a 4th edition Camel (not sure if it's in the earlier ones), have a look at Chapter 5, Section "Fancy Patterns", subsection "Grammatical Patterns". You can basically build entire grammars out of them, for example using (?&NAME) you can recurse to a named subpatten (perlre; Update: a shorter example can be found under the documentation of (DEFINE)). Whether you want to build a full grammar using Perl's regex engine instead of one of the many well-established modules is of course another question :-)

Update 2: It seems I misread the question "What is the prevalent name for this feature" as "What is the prevalent use for this feature".

Update: Used /x and brackets to make the regexes more readable, eliminating a typo in the process. Changed the order of the paragraphs. Updated wording a little bit.


In reply to Re: Parameterized Regex (updated) by haukex
in thread Parameterized Regex by QM

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.