Simplesmente construa o regex adequado
pattern "/A AND B/"
pattern "/NOT (NOT A OR NOT B)/"
Regex:
"/^(^A|^B)/"
Ou este
/(?=.*word1)(?=.*word2)/
pattern "/A AND B/"
pattern "/NOT (NOT A OR NOT B)/"
"/^(^A|^B)/"
/(?=.*word1)(?=.*word2)/