I am new to the regex world. I am trying to make a regex that is able to delimit a number from a number that is followed by a certain string.
Example:
input: '1002 900 600 700 800 234 Andrew'
output: single_numbers: 1002, 900, 600, 700, 800
special_number: 234
input: '55 89Andrew 78 622 11 22 33 44 55'
output: single_numbers: 55 78 622 11 22 33 44 55
special_number: 89
I found this regex that is able to extract the numbers : "[-+]?[.]?[\d]+(?:,\d\d\d)*[\.]?\d*(?:[eE][-+]?\d+)?"
, but it gives all available numbers:
Example:
s = '89Andrew 78 622'
re.findall("[-+]?[.]?[\d]+(?:,\d\d\d)*[\.]?\d*(?:[eE][-+]?\d+)?", s)
output: ['89', '78', '622']
How to make it work?
Thanks !!!