title: Using regular expression in find_all of Beautifulsoup
body: <p>I was trying to scrape tumblr archive, the div class tag looks like given in picture</p>
  
  <blockquote>
    <p><a href="https://i.stack.imgur.com/KsfWU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KsfWU.png" alt="enter image description here"></a></p>
  </blockquote>
  
  <p>The class starts with "post post_micro", I tried using regular expression but failed</p>
  
  <pre><code>soup.find_all(class_=re.compile('^post post_micro') 
  </code></pre>
  
  <p>I tried to use function in find_all for class</p>
  
  <pre><code>def func(x):                 
      if str(x).startswith('post_tumblelog'):
          return True
  </code></pre>
  
  <p>and used it as:</p>
  
  <pre><code>soup.find_all(class_=func)
  </code></pre>
  
  <p>The above works fine and I am getting what I need. But I want to know how to do it using regular expressions and why in the func(x),</p>
  
  <pre><code>str(x).startswith('post_tumblelog')
  </code></pre>
  
  <p>evaluates as True when the class name is starting with "post post_micro".</p>