Reputation: 151
Using match, I'd like "here" to return [ee], "heree" to return [eee] and "her" to return [null]. Also "heirei" would return [ee,ii].
Assume the string is all letters with no spaces. I imagine it involves some combination of ([\w]) and \1+, but I can't figure it out.
Thanks!
Upvotes: 0
Views: 80
Reputation: 7948
this could be done in two steps
use this pattern (.)(?!.*\1)
and replace with nothing Demo
then use the same pattern (.)(?!.*\1)
on the result and replace with $1$1
Demo
then sort final result
Upvotes: 1