Python Regex stop on string
<p>So I want to search using regex for seasons which are not followed by episode number and I have the following list :</p>

<pre><code>string = ['Fear the walking dead Season 2 Episode 9',
'Veep Season 5',
'Martine Season 2 (unknown number of episodes)',
'New Girl Season 5 Episode 16']
</code></pre>

<p>I've written this code <code>re.search('.+? Season [0-9]{1,2}', string, re.I)</code> but it seems to take into consideration the series with an episode number also.
I want it to return True only on <code>Veep Season 5</code></p>

<p>I would recommend using <code>^</code> and <code>$</code> to match from the beginning of a line to the end. So you can change your regex to:</p>

<pre><code>re.search('^(.+?Season\s[0-9]{1,2})$', string, re.I | re.M)
</code></pre>

python regex