title: using multiple variables with regex in python
body: <p>I'm trying to search strings with variable using Regular expression operations.<br/>I browsed about it and find this useful code</p>
  
  <pre><code>s = "These are oranges and apples and pears, but not pinapples or .."
  r = re.compile(r'\bAND\b | \bOR\b | \bNOT\b', flags=re.I | re.X)
  r.findall(s)
  </code></pre>
  
  <pre><code>['and', 'and', 'not', 'or'] #result
  </code></pre>
  
  <p>In this code they using exact string value 'AND''OR''NOT'.<br/>What should i do if i have something like this,</p>
  
  <pre><code>a = 'AND'
  b = 'OR'
  </code></pre>
  
  <p>(I'm getting these string values by running a loop)<br/>In this code they are using <strong>'| (or)'</strong> and <strong>re.findall()</strong>, what should i do if i need to search both <strong>a and b.</strong> and use <strong>re.search()</strong></p>
  
  <p><strong>Note:</strong> I think i need to use <code>r'\bfoo\b'</code> because sometimes my matches will be in this way...<code>'foo.', '(foo)''cod.foo'</code><br/> because of this i can't use condition like<code>if a in s: (or) if a and b in s:</code>.<br/> Please give some suggestions to work on this, Thank you. </p>