title: Create parameterized Python regular expression pattern
body: <p>I would like to create regular expression using re module.
  But it's unclear how to create a pattern in the similar way of creating a formatted string, e.g.: I need something like</p>
  
  <pre><code>myPattern = r'\s*{linehead}'.format(someText)
  </code></pre>
  
  <p>Is this possible?</p>
  
  <p>When I use </p>
  
  <p><code>if myPattern.search(l) is not None:</code>, </p>
  
  <p>I'm getting </p>
  
  <p><code>AttributeError: 'str' object has no attribute 'search'</code></p>