I would like to match all recurring characters in a string. So if I have:
aecffead
the regex should match all characters, besides c
and d
(cause those characters only occur once).
Now I already have this, which matches all characters which will occur later on in the string
/([a-z])(?=.*\1)/g
It matches these bold characters: aecffead
But it should match these bold characters: aecffead
My regex doesn't match the last "fea", cause those characters will not occur later on in the string. But because they already occurred, I want to match them as well.
Anyone who knows how to fix this? I thought about combining a positive look-ahead with a positive look-behind, but I cannot get it done.
EDIT:
Just to clarify:
The idea is to remove all characters which occur more than once. So not only the duplicates, but if character a
occurs more than once, I want to remove all a
characters from the string.