Python regular expression: how to return search value?
<p>I'm sure that this is a very elementary question, so thank you in advance for your patience. </p>

<p>I'm using a simple regular expression to identify whether a year is present in a line of text (line is a dictionary so I'm calling the particular field I want to search). Then I want to do something with the year. My question is, how can I return the year that my search finds? Everything I'm finding online tells me how to replace or edit it, but in this case the value is the thing I want to extract/use.</p>

<pre><code>p = re.compile('\d{4}')
if p.search(line['productionStartYear']):
    # do something with the value the regular expression found
else:
    # do something else
</code></pre>