|
发表于 2005-9-9 18:16:46
|
显示全部楼层
If the /c modifier is specified, the character set in SEARCHLIST is complemented; that is, the effective search list consists of all the characters not in SEARCHLIST.
Post by pnyang
#!/usr/bin/perl
#如$string =~ tr/\d/ /c;把所有非数字字符替换为空格。$string =~ tr/\t //d;删除
tab和空格; $string =~ tr/0-9/ /cs;把数字间的其它字符替换为一个空格
$string1="4546516206gjksrdhtg515trhaesjth%^&**(&415126165165156156156";
$string1=~ tr/_a-zA-Z/ /c;
print "$string1\n";
output
[root@DaleYoung chapter8]# perl eg16.pl
gjksrdhtg trhaesjth
搞不懂了,我想替换字母的,怎么数字倒全变成空格了呀?
如果把$string1=~ tr/_a-zA-Z/ /c;换成$string1=~ tr/\d/ /c;结果更吓人.
请教原因 |
|