到目前为止,我在将“$string”打印到终端之前使用这两个替换。
$string =~ s/\p{Space}/ /g;
$string =~ s/\p{Cntrl}//g;
当我用以下两个替换前两个替换时,我应该考虑什么吗?
$string =~ s/\p{Space}/ /g;
$string =~ s/\P{Print}//g;
最佳答案
参见 this question .有两个代码点既不是控制字符也不是可打印字符:U+2028 LINE SEPARATOR
和 U+2029 PARAGRAPH SEPARATOR
。但是它们都是空格字符,所以你的两个替换应该是等价的。
关于regex - 替换 : "\p{Cntrl}" - "\P{Print}",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16385235/