Re: regex help: splitting string gets weird groups

2010-04-08 Thread Patrick Maupin
On Apr 8, 3:40 pm, gry wrote: > >    >>> 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 > me

Re: regex help: splitting string gets weird groups

2010-04-08 Thread gry
>    >>> 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! -- http://mail.py

Re: regex help: splitting string gets weird groups

2010-04-08 Thread Jon Clements
On 8 Apr, 19:49, gry wrote: > [ python3.1.1, re.__version__='2.2.1' ] > I'm trying to use re to split a string into (any number of) pieces of > these kinds: > 1) contiguous runs of letters > 2) contiguous runs of digits > 3) single other characters > > e.g.   555tHe-rain.in#=1234   should give:  

Re: regex help: splitting string gets weird groups

2010-04-08 Thread gry
On Apr 8, 3:40 pm, MRAB wrote: ... > Group 1 and group 4 match '='. > Group 1 and group 3 match '1234'. > > If a group matches then any earlier match of that group is discarded, Wow, that makes this much clearer! I wonder if this behaviour shouldn't be mentioned in some form in the python docs?

Re: regex help: splitting string gets weird groups

2010-04-08 Thread Tim Chase
gry wrote: [ python3.1.1, re.__version__='2.2.1' ] I'm trying to use re to split a string into (any number of) pieces of these kinds: 1) contiguous runs of letters 2) contiguous runs of digits 3) single other characters e.g. 555tHe-rain.in#=1234 should give: [555, 'tHe', '-', 'rain', '.',

Re: regex help: splitting string gets weird groups

2010-04-08 Thread Patrick Maupin
On Apr 8, 1:49 pm, gry wrote: > [ python3.1.1, re.__version__='2.2.1' ] > I'm trying to use re to split a string into (any number of) pieces of > these kinds: > 1) contiguous runs of letters > 2) contiguous runs of digits > 3) single other characters > > e.g.   555tHe-rain.in#=1234   should give:

Re: regex help: splitting string gets weird groups

2010-04-08 Thread Jon Clements
On 8 Apr, 19:49, gry wrote: > [ python3.1.1, re.__version__='2.2.1' ] > I'm trying to use re to split a string into (any number of) pieces of > these kinds: > 1) contiguous runs of letters > 2) contiguous runs of digits > 3) single other characters > > e.g.   555tHe-rain.in#=1234   should give:  

Re: regex help: splitting string gets weird groups

2010-04-08 Thread MRAB
gry wrote: [ python3.1.1, re.__version__='2.2.1' ] I'm trying to use re to split a string into (any number of) pieces of these kinds: 1) contiguous runs of letters 2) contiguous runs of digits 3) single other characters e.g. 555tHe-rain.in#=1234 should give: [555, 'tHe', '-', 'rain', '.',

regex help: splitting string gets weird groups

2010-04-08 Thread gry
[ python3.1.1, re.__version__='2.2.1' ] I'm trying to use re to split a string into (any number of) pieces of these kinds: 1) contiguous runs of letters 2) contiguous runs of digits 3) single other characters e.g. 555tHe-rain.in#=1234 should give: [555, 'tHe', '-', 'rain', '.', 'in', '#', '=