Considering this entries...
word1 word2 word3
word2 word3 word1
word3 word1 word2
other word1 word2
other word3 word1
I can match words 1, 2 e 3 in any order (first 3 lines) with:
^(^word1|^word2|^word3) (word1|word2|word3) (word1|$word2$|word3$)$
Note that i need to find exactly this words, nothing else. But when i have more words the expression grows a lot.
e.g. (with 4 words)
^(^word1|^word2|^word3|^word4) (word1|word2|word3|word4) (word1|word2|word3|word4) (word1|$word2$|word3$|word4$)$
My question is: is there any other simpler way to do this with regex?
Aucun commentaire:
Enregistrer un commentaire