Answer the question
In order to leave comments, you need to log in
What can a regular expression do?
There is a line
"word water porridge word four water"
is it possible to use a regular expression to find out to select only those words that do not repeat?
Answer the question
In order to leave comments, you need to log in
No. The task of regular expressions is to find a match according to the pattern. Searching for non-recurring ones is a completely different algorithm.
As an option, put each word in a separate array key and remove duplicates from it using a suitable method (because I don’t know what language you have there).
The first thing that came to mind...
A regular can find a repetition, but this task is not for regulars, because you can’t do without a loop and conditions to search for nesting.
You can try
https://regex101.com/r/JxyfqR
As you can see, the first repeated "word" was found. But to search for the second repetition, it is more difficult or impossible to write.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question