I have the following string:
1 2 134 2009
And I'd like to capture the strings with between 1-3 digits, so the result should be:
['1', '2', '134']
What I have now captures those, but also captures the "first 3" digits in strings that contain more than 3 digits. This is the current regex I have:
>>> re.findall(r'\d{1,3}', '1 2 134 2009')
['1', '2', '134', '200', '9']
# or a bit closer --
>>> re.findall(r'\d{1,3}(?!\d)', '1 2 134 2009')
['1', '2', '134', '009']
What would be the correct way to make sure that another digit doesn't immediate proceed it?