Re: string split without consumption

2008-02-02 Thread robert
Steve Holden wrote: > robert wrote: > [...] >> but its also wrong regarding partial last lines. >> >> re.split obviously doesn't understand \A \Z ^ $ and also \b etc. empty >> matches. >> > [...] > Or perhaps you don't understand re? > > It's a tricky thing to start playing with. Look up re.MULTI

Re: string split without consumption

2008-02-02 Thread Steve Holden
robert wrote: [...] > but its also wrong regarding partial last lines. > > re.split obviously doesn't understand \A \Z ^ $ and also \b etc. > empty matches. > [...] Or perhaps you don't understand re? It's a tricky thing to start playing with. Look up re.MULTILINE ans re.DOTALL. regards Ste

Re: string split without consumption

2008-02-02 Thread robert
Jeffrey Froman wrote: > robert wrote: > >> thanks. Yet this does not work "naturally" consistent in my line >> processing algorithm - the further buffering. Compare e.g. >> ss.split('\n') .. >> > 'owi\nweoifj\nfheu\n'.split('\n') >> ['owi', 'weoifj', 'fheu', ''] > 'owi\nweoifj\nfheu\nxx'.

Re: string split without consumption

2008-02-02 Thread robert
Tim Chase wrote: this didn't work elegantly as expected: >>> ss 'owi\nweoifj\nfheu\n' >>> re.split(r'(?m)$',ss) ['owi\nweoifj\nfheu\n'] >>> Do you have a need to use a regexp? >> I'd like the general case - split without consumption. > > I'm not sure there's a one-p

Re: string split without consumption

2008-02-02 Thread Jeffrey Froman
robert wrote: > thanks. Yet this does not work "naturally" consistent in my line > processing algorithm - the further buffering. Compare e.g. > ss.split('\n')  .. > > >>> 'owi\nweoifj\nfheu\n'.split('\n') > ['owi', 'weoifj', 'fheu', ''] > >>> 'owi\nweoifj\nfheu\nxx'.split('\n') > ['owi', 'weoifj'

Re: string split without consumption

2008-02-02 Thread Tim Chase
>>> this didn't work elegantly as expected: >>> >>> >>> ss >>> 'owi\nweoifj\nfheu\n' >>> >>> re.split(r'(?m)$',ss) >>> ['owi\nweoifj\nfheu\n'] >> Do you have a need to use a regexp? > > I'd like the general case - split without consumption. I'm not sure there's a one-pass regex solution to the

Re: string split without consumption

2008-02-02 Thread robert
Tim Chase wrote: >> this didn't work elegantly as expected: >> >> >>> ss >> 'owi\nweoifj\nfheu\n' >> >>> re.split(r'(?m)$',ss) >> ['owi\nweoifj\nfheu\n'] > > Do you have a need to use a regexp? I'd like the general case - split without consumption. > ss.splitlines(True) > ['owi\n', 'weoi

Re: string split without consumption

2008-02-02 Thread Tim Chase
> this didn't work elegantly as expected: > > >>> ss > 'owi\nweoifj\nfheu\n' > >>> re.split(r'(?m)$',ss) > ['owi\nweoifj\nfheu\n'] Do you have a need to use a regexp? >>> ss.splitlines(True) ['owi\n', 'weoifj\n', 'fheu\n'] -tkc -- http://mail.python.org/mailman/listinfo/python-list

string split without consumption

2008-02-02 Thread robert
this didn't work elegantly as expected: >>> ss 'owi\nweoifj\nfheu\n' >>> re.split(r'\A',ss) ['owi\nweoifj\nfheu\n'] >>> re.split(r'\Z',ss) ['owi\nweoifj\nfheu\n'] >>> re.split(r'$',ss) ['owi\nweoifj\nfheu\n'] >>> re.split(r'(?s)$',ss) ['owi\nweoifj\nfheu\n'] >>> re.split(r'(?m)(?s)$',ss) ['o