Partial Regex Matching
<p>I am inquiring about partial regex matching in Python.</p>

<p><strong>For Example:</strong></p>

<p>If you have a string:  </p>

<pre><code>string = 'foo bar cat dog elephant barn yarn p n a'
</code></pre>

<p>And a regex:  </p>

<pre><code>pattern = r'foo bar cat barn yard p n a f'
</code></pre>

<p>The following would be true:</p>

<ul>
<li><code>re.match(pattern, string)</code> Would return <code>None</code>.</li>
<li><code>re.search(pattern, string)</code> Would also return <code>None</code></li>
</ul>

<p>Although we can all see that the first part of the pattern matches the first part of the string.</p>

<p>So instead of searching for the entirety of the pattern in the string, is there a way to see what percentage of the string matched the pattern?</p>