For example:
I want to match duplicate characters that are separated by other characters:
- Matching
stress
should returnsss
- Matching
lambda
should returnaa
- Matching
moonmen
should returnmoonmn
I am close, getting the first character of every duplicate by using lookaheads:
['stress','lambda','moonmen'].forEach( (e) => {
console.log( e.match(/(.)(?=.*\1)/g) )
} )
But how would I get all duplicate characters?