For example:
I want to match duplicate characters that are separated by other characters:
- Matching
stressshould returnsss - Matching
lambdashould returnaa - Matching
moonmenshould 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?