How can regular expressions be effectively used to solve the issue of removing duplicates from a string in PHP?

To remove duplicates from a string in PHP using regular expressions, we can use the `preg_replace` function to match and replace duplicate occurrences of characters. By using a regex pattern that captures repeated characters, we can replace them with a single instance of the character. This approach allows us to efficiently remove duplicates from a string without the need for complex looping or comparison logic.

$string = "helloo";
$clean_string = preg_replace('/(.)\1+/', '$1', $string);
echo $clean_string; // Output: helo