regex help: splitting string gets weird groups

gry georgeryoung at gmail.com
Thu Apr 8 16:40:16 EDT 2010


>    >>> s='555tHe-rain.in#=1234'
>    >>> import re
>    >>> r=re.compile(r'([a-zA-Z]+|\d+|.)')
>    >>> r.findall(s)
>    ['555', 'tHe', '-', 'rain', '.', 'in', '#', '=', '1234']
This is nice and simple and has the invertible property that Patrick
mentioned above.  Thanks much!



More information about the Python-list mailing list