Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Just a simple regex I don't know how to write.

The regex has to make sure a string matches all 3 words. I see how to make it match any of the 3:

/advancedbrain|com_ixxocart|p=completed/

but I need to make sure that all 3 words are present in the string.

Here are the words

  1. advancebrain
  2. com_ixxocart
  3. p=completed
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
501 views
Welcome To Ask or Share your Answers For Others

1 Answer

Use lookahead assertions:

^(?=.*advancebrain)(?=.*com_ixxochart)(?=.*p=completed)

will match if all three terms are present.

You might want to add work boundaries around your search terms to ensure that they are matched as complete words and not substrings of other words (like advancebraindeath) if you need to avoid this:

^(?=.*advancebrain)(?=.*com_ixxochart)(?=.*p=completed)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...