This question already has an answer here:
Lets say I have a string:
Using the power of regex, how can that string be turned into:
At first look it seems easy to do, but the current code (not regex) I have for it is not behaving well and im pretty sure regex is the way to go.
Best How To :
The above regex captures the first character in the sequence of same characters and matches all the following one or more characters (which must be same as the one inside the capturing group) . Replacing those characters with the character inside group index 1 will give you the desired output.