I am trying to perform a regex that matches if both the word cat AND dog are in the regex with multi-line support
matches
cat asdjfaldsfj dog
####
does NOT match
cat adfasdf8989
####
matches
dog adlsjf88989 cat
####
matches
cat asdf8a89sdf8
a sdf asd f ads f ads fasdf
dog a dsf ads fads f
asdfadsfadsf
The regex I'm using is pretty simple
/^(?=.*\bcat\b)(?=.*\bdog\b).*$/gs
The problem is that this only finds the first occurrence since it is greedy. I really want the following to count two matches but it only matches once
cat asdf8a89sdf8
a sdf asd f ads f ads fasdf
dog a dsf ads fads f
asdfadsfadsf
cat asdf8a89sdf8
a sdf asd f ads f ads fasdf
dog a dsf ads fads f
asdfadsfadsf
Even without the second set of cat STUFF dog STUFF the regex still matches until the end.