Regular expression – how to delete duplicate characters, but leave two?

If there are more than 2 characters
“Hiiiiiii
My friend!!!!!!!”

I need to reduce to
“Fei Yichuan
My friend!!”

Please note that in my language, there are many double-character words.
Thnx in advance

kplla

Perl / regex (if it’s not in English, Perl gives me better than Unicode Luck):

#!/usr/bin/perl

$str = "Hiiiiii My Frieeeeend!!!!!!! ";

$str =~ s/(.)+/$1$1/g;

print $str;

If there are more than 2 characters
“Hiiiiiii
My friend!!!!!!!”

I need to reduce to
” Fei Chuan
My friend!!”

Please note that in my language, there are many double-character words.
Thnx in advance

kplla

Perl / regex (If it is not in English, Perl gave me better luck than Unicode):

#!/usr/bin/perl

$str = "Hiiiiii My Frieeeeend!!!!!!!";

$str =~ s/ (.)+/$1$1/g;

print $str;

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5439 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.