"Nothing" 环顾四周 [RAKU]
"Nothing" in Lookaround terms [RAKU]
我正在阅读有关 "Tilde for nesting structures" 的正则表达式文档。
旁白关于<?>
的使用说明是:
Here <?>
successfully matches the null string.
我以为我可以使用 <?[]>
代替它,但它没有这样做!
举个例子:
say so "" ~~ / <?> /;
say so "test" ~~ / <?> /;
say so "" ~~ / <?[]> /;
say so "test" ~~ / <?[]> /;
回复:
True
True
False
False
有人可以给我解释一下吗?
语法<?[]>
表示先行匹配空字符class。观察到空字符 class 也永远不会匹配:
say "x" ~~ /<[]>/ # Nil
一个字符class指定一组可以匹配的字符。空字符 class 表示一组空字符,因此不可能匹配任何内容。
我正在阅读有关 "Tilde for nesting structures" 的正则表达式文档。
旁白关于<?>
的使用说明是:
Here
<?>
successfully matches the null string.
我以为我可以使用 <?[]>
代替它,但它没有这样做!
举个例子:
say so "" ~~ / <?> /;
say so "test" ~~ / <?> /;
say so "" ~~ / <?[]> /;
say so "test" ~~ / <?[]> /;
回复:
True
True
False
False
有人可以给我解释一下吗?
语法<?[]>
表示先行匹配空字符class。观察到空字符 class 也永远不会匹配:
say "x" ~~ /<[]>/ # Nil
一个字符class指定一组可以匹配的字符。空字符 class 表示一组空字符,因此不可能匹配任何内容。