I have some strings that are stored in a dataframe using pandas and I want to extract all numbers out of them if it exists. The conditions these numbers must meet are quite specific and I'm not really sure if I can use regex to solve my problem. The conditions are:
- The number CANNOT be at the start of the string
- It CANNOT appear after the word "No. " or after the word "Question "
Also if possible, if the number has an e right after it I would want to keep that as well. However this is less important.
This is what I have so far to find all the numbers, but I do not know how to code the conditions I mentioned above.
testNumbers = re.findall(r'\d+', row['Name'])
For a given string: " Test T860 Article No. 9712250 787"
I would want the regex expression to return
[860, 787]
