这是一个这样的句子:
Happy birthday!! I have a good day. :)
我想知道如何使用正则表达式将这些句子处理为以下格式:
Happy birthday! I have a good day.
答案 0 :(得分:2)
以下是如何在PERL中执行此操作(因为您未指定编程语言。
my $str = "Happy birthday!! I have a good day. :)";
$str =~ s/([.!?]){2,}/$1/g; #remove multiple punctuation
$str =~ s/[:;()]+//g; #remove emoticon
print $str;