Is it possible to use a regular expression to match all words, but only for unique words? I know that there are other ways to do this, however I am interested in knowing if this is possible using regular expression.
For example, I currently have the following expression:
(\w+\b)(?!.*\1)
and the following line:
glass shoes door window door glasses. window glasses
For the most part, the expression works and matches the following words:
shoes door window glasses
There are two problems with this:
Matching a substring is done on โglassesโ with โglassโ, this is not true.
"glasses" and "glasses". should match, but not at present.
The final match should be:
shoes door window glasses glass
source share