How to extract substring with regex in Python code

We have a string:

"and a[x, 152] > 44.127895465113006 because 1368.1 > 1247.0"

We need to extract 152 from it. This python code will do the thing:

import re
r = re.search('and\ a\[x,\ (.+?)\]', l)
print(r.group(1))

So if you run the code it prints "152".