如何使点 ( .) 元字符匹配 Raku 正则表达式中的换行符?在 Perl 中,我会使用点匹配换行符( /s)?
$+{name}Perl 正则表达式变量之间以及$-{name}两者用于从 Perl 语句/表达式代码引用同一正则表达式组时有什么区别?
如何在 Raku 正则表达式中插入条件代码
正则表达式 与 Perl 正则表达式类似
my $F = 1;
'foobarbar' =~ / (?(?{ $F }) foo | bar ) bar /x ;
Run Code Online (Sandbox Code Playgroud)
辛苦了一天了,没有结果,请大家帮忙,谢谢。
我们如何知道并确定循环的当前点是否是最后一个(因为在 Perl 中由于有 \ ref. 运算符可见而简单地完成了这一点)?
编辑后的更正链接: https://perlmonks.org/? node_id=11140741
请帮忙指出解决方法。谢谢
Raku 递归正则表达式语法和 Raku 中的所有匹配变量是什么或如何作为尝试
'hellohelloworldworld' ~~ m{ ^(h\w+?o) (?0) world };
say "\n=$&"
Run Code Online (Sandbox Code Playgroud)
似乎不起作用
请帮忙解决这些问题。
我们如何做 Perl 的'
$inp=<>;
在 Raku 中提示用户一行?
由于lines();不断提示用户输入,因此工作方式不同
请帮忙澄清一下
Raku 在交替捕获组上的行为如何与 Perl 正则表达式的行为一样,例如
\n> 'abefo' ~~ /a [(b) | (c) (d)] (e)[(f)|(g)]/\n\xef\xbd\xa2abef\xef\xbd\xa3\n 0 => \xef\xbd\xa2b\xef\xbd\xa3\n 2 => \xef\xbd\xa2e\xef\xbd\xa3\n 3 => \xef\xbd\xa2f\xef\xbd\xa3\nRun Code Online (Sandbox Code Playgroud)\n需要是“通常的”Perl 正则表达式结果(让索引系统保持 Raku):
\n $0 = 'b'\n $1 = undef\n $2 = undef \n $3 = e\n $4 = f\nRun Code Online (Sandbox Code Playgroud)\n请给予有用的指导。
\n最简单的 Raku 是如何从正则表达式捕获的结果中按相应的顺序填充这么多单独的变量
(就像 Perl 一样) my ($a, $b $c, $d, $e)= 'hello' =~ m{ ^(h) (e) (l) (l) (o) }x
)?
尝试这样的:
> my ($a, $b, $c, $arr);
[<$a $b $c>]= 'hello world' ~~ m{ (h)(e)(l)lo };
say "\n=$a\n=$b\n=$c"
Use of uninitialized value element of type Any in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
in block <unit> at <unknown file> line 1
Run Code Online (Sandbox Code Playgroud)
...
失败了。
请给出正确且最接近Perl的类似方式。
我们如何将 Match(或其他)对象展平或字符串化为字符串数据类型(尤其是大量,即作为数组元素)?例如
'foobar' ~~ m{ (foo) };
say $0.WHAT;
my $foo = $0;
say $foo.WHAT
Run Code Online (Sandbox Code Playgroud)
(Match)
(Match)
Run Code Online (Sandbox Code Playgroud)
结局如何(Str)?
如何像在 C 中一样打印出 Nim 地址:
int array[] = { 7, 8, 9 };
printf(" %p ", (void *)&array);
Run Code Online (Sandbox Code Playgroud)
?尝试:
var
arr = newSeq[array[2,int]](2)
refVar = addr arr
echo refVar
Run Code Online (Sandbox Code Playgroud)
给了:
Error: type mismatch: got <ptr seq[array[0..1, int]]>
but expected one of:
proc echo(x: varargs[typed, `$`])
first type mismatch at position: 1
required type for x: varargs[typed]
but expression 'refVar' is of type: ptr seq[array[0..1, int]
Run Code Online (Sandbox Code Playgroud)
请大家帮忙!