> "abc" ~~ m/()abc/===SORRY!=== Error while compiling:Null regex not allowed> my regex null {}===SORRY!=== Error while compiling:Null regex not allowed> my regex null {<[]>}regex null {<[]>}> "abc" ~~ m/<null>abc/False
当然我可以使用类似下面的内容,但我正在寻找一种惯用的方法.
> my regex null {a ** 0}regex null {a ** 0}> "abc" ~~ m/<null>abc/「abc」 null => 「」
UPD:这有效,但这是最好的方法吗?
> my regex null { '' }regex null { '' }> "abc" ~~ m/<null>abc/「abc」 null => 「」> "abc" ~~ m/('') abc/「abc」 0 => 「」解决方法 始终成功并匹配0个字符的断言是:<?>.
例如:
say so 'foo' ~~ / <?> 'foo' /;# output: True
正如raiph所指出的那样,总是失败的相应负面版本是<!>.如果输入有效,我已经使用它来在不应该达到部分解析时插入错误消息.正则表达式的那一部分可能是:
\d || [ { note "Error: the prevIoUs token must be followed by a number."; } <!> ]总结
以上是内存溢出为你收集整理的perl6 – 在Perl 6中使正则表达式完全匹配零字符的最佳方法?全部内容,希望文章能够帮你解决perl6 – 在Perl 6中使正则表达式完全匹配零字符的最佳方法?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)