【发布时间】:2017-06-11 19:14:21
【问题描述】:
我试图忽略所有带有引号的行,不知何故它有点令人困惑:
> my $y='\"\""';
\"\""
> so $y ~~ m/<-[\"]>/
True # $y has a " mark, so I want it to be False
> $y ~~ m/<-[\"]>/
「\」
> $y ~~ m:g/<-[\"]>/
(「\」 「\」)
> $y ~~ m:g/<-["]>/
(「\」 「\」)
$y ~~ m/<-[\\]>/
「"」
> $y ~~ m/<-[\\\"]>/
False
和 一样吗?
> say '"in quotes"' ~~ / '"' <-[ " ]> * '"'/;
「"in quotes"」
> say 'no "foo" quotes' ~~ / <-[ " ]> + /;
「no 」
> say 'no "foo" quotes' ~~ / <-[ \" ]> + /;
「no 」
在 perl6 文档示例中,https://docs.perl6.org/language/regexes#Wildcards_and_character_classes,作者不必转义引号;但是,我必须逃避它才能工作, ,即逃避 \ 和逃避“。我误会了什么?
谢谢!!
【问题讨论】: