用(正则表达式)统计文件中所有英文单词的数量,符号、空格、数字不再识别范围之内(大小写不计算在内)Nowis the timefor all good-mento come to the-aid of -theirparty.NOW IS THE TIME FOR all Good men tocome t
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 19:35:21
用(正则表达式)统计文件中所有英文单词的数量,符号、空格、数字不再识别范围之内(大小写不计算在内)Nowis the timefor all good-mento come to the-aid of -theirparty.NOW IS THE TIME FOR all Good men tocome t
用(正则表达式)统计文件中所有英文单词的数量,符号、空格、数字不再识别范围之内(大小写不计算在内)
Now
is the time
for all good-men
to come to the-
aid of -their
party.NOW IS THE TIME FOR all Good men to
come to the AID of their party.party-their now-is time-the-for all-good
men to -come aid of party a&b%c*(d)
a1b2c3d4-
a
b
b c defg
thisisaverylongWORDwithnospacesbetweenthewordsandhowwillitbehandled?
thisisaverylongWORDwithnospacesbetweenthewordsandhowwillitbehandled2?
thisisaverylongWORDwithnospacesbetweenthewordsandhowwillitbehandled3?
%^&*()
用(正则表达式)统计文件中所有英文单词的数量,符号、空格、数字不再识别范围之内(大小写不计算在内)Nowis the timefor all good-mento come to the-aid of -theirparty.NOW IS THE TIME FOR all Good men tocome t
#!/usr/bin/perl
open IN,"as.txt";
while(){
@line=split/\s+/,$_;
foreach $line(@line){
$count++ if ($line=~/^\w+$/);
}
}
print $count."\n";
$count=36