I have a simple string with some repeating characters. Can someone please help me fix the expression below to remove not only duplicate characters but all characters that occur more than 1 time.
console.log('aaabbxxstring'.replace(/(.)(?=.*?)/g,'')); // string
I am using lookahead to capture matching characters and replace the match with spaces. The question is how to replace the capturing group itself. Or is the entire approach incorrect?
illustrate:
When you split a string around characters, use the length of the resulting array to count occurrences.
Provides you with the number of occurrences plus 1.
Convert the string to an array, filter by the number of occurrences, and connect to the string.