How do you write a regex to match if any two words are present in a string, in any order?
Ie, I’m trying to write a regex that would find any string with “reset” and “password” in it, case insenstive. So, these should match:
- Reset password
- Password reset
- You reset your password
- Your password reset request
- Your password has been reset
And these should not match
- password
- reset
- password changed
- account reset
The closest I got was: /(password|reset)/, but that finds every case, and when I tried (password|reset){2} it didn’t match any. Testing this out on rubular.
You can try