Я пытаюсь использовать ~ для вложенных структур для анализа кавычек, которые являются одинарными или двойными кавычками;когда кавычка совпадает, она сохраняется в $ 0, и единственный способ использовать ее - записать $ 0;Есть ли другой способ выразить значение $ 0 внутри регулярного выражения?
my regex linkIndicator { [ href \= || src \= || content \= ] };
my regex aLink0 { \< <-[<]>*? <linkIndicator> <-[>]>*? \> };
my regex aLink1 { <linkIndicator> (\" || \') ~ $0 <-['"]>*? }; # works;
my regex aLink3 { <linkIndicator> (\" || \') ~ "{$/[0]}" <-['"]>*? }; # does not works;
my regex aLink4 { <linkIndicator> (\" || \') ~ $({$/[0]}) <-['"]>*? }; # does not works; cannot convert block object to string;
my regex aLink5 { <linkIndicator> (\" || \') ~ $(do {$/[0]}) <-['"]>*? }; # does not works;
my regex aLink6 { <linkIndicator> (\" || \') ~ $($/[0]) <-['"]>*? }; # does not works;
my regex aLink7 { <linkIndicator> (\" || \') ~ $(~$/[0]) <-['"]>*? }; # does not works;
my regex aLink8 { <linkIndicator> (\" || \') ~ $0 <-['"]>*? }; # works;
my regex aLink9 { <linkIndicator> [\" || \'] <-['"]>*? [\" || \'] }; # works;
my $pageInString = "href=\"/foo.com\" <a src=\"http://bar.com/\" /> "; # slurp( @*ARGS[0] );
for ( $pageInString ~~ m:g:i/ <aLink0> / ) { say ~$_; }; # ok
say "=" x 50;
for ( $pageInString ~~ m:g:i/ <aLink1> / ) { say ~$_; }; # ok
say "=" x 50;
for ( $pageInString ~~ m:g:i/ <aLink3> / ) { say ~$_; }; # fails
say "=" x 50;
for ( $pageInString ~~ m:g:i/ <aLink4> / ) { say ~$_; }; # fails
say "=" x 50;
for ( $pageInString ~~ m:g:i/ <aLink5> / ) { say ~$_; }; # fails
say "=" x 50;
for ( $pageInString ~~ m:g:i/ <aLink6> / ) { say ~$_; }; # fails
say "=" x 50;
for ( $pageInString ~~ m:g:i/ <aLink7> / ) { say ~$_; }; # fails
say "=" x 50;
for ( $pageInString ~~ m:g:i/ <aLink8> / ) { say ~$_; }; # ok
say "=" x 50;
for ( $pageInString ~~ m:g:i/ <aLink9> / ) { say ~$_; }; # ok
my regex aLink2 { <linkIndicator> (\" || \') ~ <{$/[0]}> <-['"]>*? }; # error, crashes program; Unable to parse expression in double quotes; couldn't find final '"' (corresponding starter was at line 1)
say "=" x 50;
for ( $pageInString ~~ m:g:i/ <aLink2> / ) { say ~$_; };