I have the folowing regex code in php that its find and replace all repeating characters.
$parts = explode("@", 'aaabbbddddeeesd@yahoo.com');
$username = $parts[0];
$domain = $parts[1];
$out = preg_replace('/(.)\1+/', '$1', $username);
$email = $out . '@' . $domain;
print_r($email);
This code is replacing all repeating characters, but i need only to replace only for the first group from the beginning of the string.
Example aaabbbddddeeesd@yahoo.com i need the output to be abbbddddeeesd@yahoo.com
I have tried different regex but only this was working until now.
Thanks