As a rule of thumb:

Every non-Letter character after the opening angle bracket makes it non-capturing.

Am 22.02.2016 um 11:37 schrieb Theo van den Heuvel:
Thanks Patrick,

it works great.


Patrick R. Michaud schreef op 2016-02-22 11:16:
Dynamic subregexes such as <$top> are non-capturing by default.  You
can easily capture the result by using something like <top=$top>

    $ cat xyz.p6
    my $match;

    my $top = rx/ \( $<core> = [ \w* ] \) /;

    given "(abc)" {
       $match = m/^ <top=$top> /;

    if $match {
       say "core is { ~$<top><core> }";

    $ ./perl6 xyz.p6
    core is abc

Hope this helps,


On Mon, Feb 22, 2016 at 10:25:19AM +0100, Theo van den Heuvel wrote:
Hi all,

I am trying to change a regex programmatically. For that I insert a variable in another regex. However, the match object appears to have lost the capture
of the inner regex. In a code example:

my Match $match;

my $top = rx/ \( $<core> = [ \w* ] \) /;

given "(abc)" {
  $match = m/^ <$top>/;

if $match {
  say "core is { ~$<core> }";


Using the latest rakudo release (2016.01.1), I find that the matching
process works but the capture gets lost. Any ideas?


Theo van den Heuvel
Van den Heuvel HLT Consultancy

Reply via email to