re.split() not keeping matched text
no_replies at fake_email_address.invalid
Sun Jul 25 22:07:51 CEST 2004
"Test" <usenet at diefenba.ch> wrote in message
news:ce12hh$vc9$06$1 at news.t-online.com...
> Hi Robert,
> The docs say: If _capturing parentheses_ are used in pattern, then the
> of all groups in the pattern are also returned as part of the resulting
> l = re.split("([.?!])", x)
> will work as wanted.
That works. Unfortunately the punctuation marks (matched text) are returned
as separate list entries. Is there any way to avoid having to walk the list
by steps of 2, and rejoin the "n" and "n+1" elements, to get back the
original sentence(s)? I'm trying to save some processing time if possible.
More information about the Python-list