title: How to search for the last occurrence of a regular expression in a string in python?
body: <p>In python, I can easily search for the first occurrence of a regex within a string like this:</p>
  
  <pre><code>import re
  re.search("pattern", "target_text")
  </code></pre>
  
  <p>Now I need to find the last occurrence of the regex in a string, this doesn't seems to be supported by <code>re</code> module.</p>
  
  <p>I can reverse the string to "search for the first occurrence", but I also need to reverse the regex, which is a much harder problem.</p>
  
  <p>I can also iterate to find all occurrences from left to right, and just keep the last one, but that looks awkward.</p>
  
  <p>Is there a smart way to find the rightmost occurrence?</p>