Forum Moderators: coopster
I have alot of text with double letters. Something like:
"add" should be "ad"
"allot" should be "alot"
ETC.
Being terrible at regular expressions I am looking for a preg_replace that replaces these double letters with just a single letter.
Any ideas on how this can be accomplished? It seems like a toughie -
Thank you in advance,
Ron
$string = "Hello there dubble letters!";
$pattern = "/([a-z])\\1/Uis";
$replacement = "$1";
print "$string<br />";
print preg_replace($pattern, $replacement, $string);
"I want to allot some serious money to adding a star-studded add campaign to our program that will help allot".
becomes
"I want to alot some serious money to ading a star-studed ad campaign to our program that will help alot".
Your regex takes a sentence with two errors and creates a sentence with four errors.
The correct version (uhh, in terms of spelling - it's still a terrible sentence of course) would be
"I want to allot some serious money to adding a star-studded ad campaign to our program that will help a lot".