How do I write a regular expression to match two given strings, at any position in the string?
For example, if I am searching for cat and mat
cat
mat
If you absolutely need to only use one regex then
/(?=.*?(string1))(?=.*?(string2))/is
i modifier = case-insensitive
.*? Lazy evaluation for any character (matches as few as possible)
?= for Positive LookAhead it has to match somewhere
s modifier = .(period) also accepts line breaks