I have the folowing regex code in php that its find and replace all repeating characters.
$parts = explode("@", '[email protected]');
$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 [email protected] i need the output to be [email protected]
I have tried different regex but only this was working until now.
Thanks