Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是一个这样的句子:
Happy birthday!! I have a good day. :)
我想知道如何使用正则表达式将这些句子处理为以下格式:
Happy birthday! I have a good day.
以下是如何在 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;