Thanks Patrick,
it works great.
Theo
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>
instead:
$ 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,
Pm
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?
Thanks,
--
Theo van den Heuvel
Van den Heuvel HLT Consultancy
--
Theo van den Heuvel
Van den Heuvel HLT Consultancy
Malden, The Netherlands
+31 24 3736356
+31 625492788