How to match multiple words in regex

隐身守侯 提交于 2019-11-29 03:41:32

Use lookahead assertions:

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

will match if all three terms are present.

You might want to add \b 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:

^(?=.*\badvancebrain\b)(?=.*\bcom_ixxochart\b)(?=.*\bp=completed\b)
^(?=.*?p=completed)(?=.*?advancebrain)(?=.*?com_ixxocart).*$

Spent too long testing and refining =/ Oh well.. Will still post my answer

Use lookahead:

(?=.*\badvancebrain)(?=.*\bcom_ixxocart)(?=.*\bp=completed)

Order won't matter. All three are required.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!