相关疑难解决方法(0)

perl6如何在正则表达式插值中使用连接?

有时我有一个很长的列表,我想检查一个字符串是否匹配列表中的任何内容.我试图在正则表达式内插入一个结点.他们都是错误.

say "12345" ~~ m/ <{ (2,3,4).any }> /
Cannot resolve caller MAKE_REGEX(Int, Bool, Bool, Int, PseudoStash); none of these signatures match:

say "12345" ~~ m/ $( (2,3,4).any ) /
This type cannot unbox to a native string: P6opaque, Junction
Run Code Online (Sandbox Code Playgroud)

此错误消息是否表示无法在正则表达式插值中使用联结?

我的解决方法是

say "12345" ~~ m/ <{ (2,3,4).join("||") }> /
?2?
Run Code Online (Sandbox Code Playgroud)

有关在正则表达式插值中使用连接的任何建议吗?

非常感谢你 !!!

lisprog

regex interpolation perl6 junction

7
推荐指数
1
解决办法
140
查看次数

标签 统计

interpolation ×1

junction ×1

perl6 ×1

regex ×1