views:

34

answers:

1

Here is a sentence like this:

Happy birthday!! I have a good day. :)

I want to know how to process these sentence using regular expression to the following formate:

Happy birthday! I have a good day.
+2  A: 

Here's how to do it in PERL (since you didn't specify a programming language.

my $str = "Happy birthday!! I have a good day. :)";
$str =~ s/([.!?]){2,}/$1/g;    #remove multiple punctuation
$str =~ s/[:;()]+//g;          #remove emoticon
print $str;
Ruel
Or even in Perl, the correct spelling of the language :-)
justintime