Pit*_*kos 6 regex unicode perl special-characters
我无法摆脱字符串中的特殊字符¤和❤:
$word = 'c?i¤r$c?u¨s';
$word =~ s/[^a-zöäåA-ZÖÄÅ]//g;
printf "$word\n";
Run Code Online (Sandbox Code Playgroud)
在第二行,我尝试从字符串中删除任何非字母字符$word.我希望打印出马戏团这个词,但我得到:
ci?rc?us
Run Code Online (Sandbox Code Playgroud)
表达式中的öäå和ÖÅ只是我需要的瑞典字母表中的普通字符.
cho*_*oba 11
如果字符在您的源代码中,请务必use utf8.如果从文件中读取它们,binmode $FILEHANDLE, ':utf8'.
一定要阅读perldoc perlunicode.
| 归档时间: |
|
| 查看次数: |
1784 次 |
| 最近记录: |