Suppose I have a sequence of characters:
var str = "aaaa aaa aaaaaa safsd a a a aaaa";
Note: The character a
may be repeated several times,
I want to replace all instances of connected a
s with just one a
. For instance, replacing aaaa
with a
, the desired output from the given str
would look like this:
Output:
a a a safsd a a a a