title: IF statement with AND/OR conditions defined by a string
body: <p>I have an input string ('text') that I want to check if it includes a series of words through a complex AND/OR combination, for instance something like:</p>
  <pre><code>if (&quot;alarm&quot; in text or &quot;arm&quot; in text or &quot;clock&quot; in text) and (&quot;which&quot; in text or (&quot;list&quot; in text or &quot;least&quot; in text) or &quot;do i have&quot; in text):
  </code></pre>
  <p>This AND/OR combination example could be expressed in a simple way as:</p>
  <p>'(alarm|arm|clock)&amp;(which|(list|least)|do I have)'</p>
  <p>So my goal is to have strings in a simple format, such as the previous one, stored in a file and to have my python code accessing it and performing an IF check on 'text' according to that AND/OR combination. I don't mind changing a bit the format (like swapping '|' for '/' or '&amp;' for '+') if the format is still humanly visually simple.</p>
  <p>I didn't find any way to adjust the number of AND/OR in an IF statement according to a string and trying to create a custom function that would carefully analyse the string and check one by one the words in the order dictated by the generic parenthesis hierarchy proved to be too challenging for me.</p>
  <p>I read that regular expressions could be the solution here but after going through its documentation I didn't figure out a way to do those AND/OR combinations taking into account that the words in 'text' could come in any order. I think regex is just too powerful for the simple &quot;word in text&quot; check that I want to make.</p>
  <p>Is there any other more elegant way to do this that I am missing?</p>