How to find characters ahead of word using re?
<p>So I would like to obtain the number that is ahead of the word pies. How would I do this?</p>

<pre><code>import re
string='latin 1,394 pies'
m = re.search('', string)
print(m.group(0))
#want 1,394
</code></pre>

<pre><code>In [137]: import re
     ...: string='latin 1,394 pies'
     ...: m = re.search(r'([\d,]+) pies', string)
     ...: print(m.group(1))
     ...: 
1,394



([\d,]+) pies
</code></pre>

<p><img src="https://www.debuggex.com/i/gXGzdV9i3-VyuTBM.png" alt="Regular expression visualization"></p>

<p><a href="https://regex101.com/r/dT8gE8/1" rel="nofollow">Regex101 Explanation</a></p>

python regex