Extract Number from String in Python
This code works fine. There is definitely some other problem:
>>> str1 = "3158 reviews"
>>> print (re.findall('\d+', str1 ))
['3158']
You can filter
the string by digits using str.isdigit
method,
>>> int(filter(str.isdigit, str1))
3158