Regex: Matching a space-joined list of words, excluding last whitespace
- by Jesper
How would I match a space separated list of words followed by whitespace and some optional numbers?
I have this:
>>> import re
>>> m = re.match('(?P<words>(\w+\s+)+)(?P<num>\d+)?\r\n', 'Foo Bar 12345\r\n')
>>> m.groupdict()
{'num': '12345', 'words': 'Foo Bar '}
I'd like the words group to not include the…