在字符 类 中包含不间断空格
Including non-breaking whitespace in character classes
在 Perl6 中,不间断 space 被认为是 space,所以
say 'Perl 6' ~~ / / # Please understand there's a no-break space in the middle
生产
Null regex not allowed
解决方法是引用字符,像这样
say 'Perl 6' ~~ / ' ' / ; # OUTPUT: «「 」»
但是,如果您想将不间断 space 包含到字符 class 中,那将不起作用:
$str ~~ /<[ & < > " ' { ]>/ )
我可以使用 Zs
,这是一个 space 分隔符,但那个分隔符似乎更宽泛...还有其他方法吗?
引用也无济于事。问题是,我应该在那里使用什么字符 class?
尝试:
$str ~~ /<[ & < > " ' { \xA0 ]>/
或更具可读性:
$str ~~ /<[ & < > " ' { \c[NO-BREAK SPACE] ]>/
在 Perl6 中,不间断 space 被认为是 space,所以
say 'Perl 6' ~~ / / # Please understand there's a no-break space in the middle
生产
Null regex not allowed
解决方法是引用字符,像这样
say 'Perl 6' ~~ / ' ' / ; # OUTPUT: «「 」»
但是,如果您想将不间断 space 包含到字符 class 中,那将不起作用:
$str ~~ /<[ & < > " ' { ]>/ )
我可以使用 Zs
,这是一个 space 分隔符,但那个分隔符似乎更宽泛...还有其他方法吗?
引用也无济于事。问题是,我应该在那里使用什么字符 class?
尝试:
$str ~~ /<[ & < > " ' { \xA0 ]>/
或更具可读性:
$str ~~ /<[ & < > " ' { \c[NO-BREAK SPACE] ]>/