regular expresson for Unix and Dos Lineendings wanted
Franz Steinhäusler
franz.steinhaeusler at gmx.at
Fri Feb 24 12:01:02 EST 2006
On Fri, 24 Feb 2006 07:21:04 -0500, John Zenger
<john_zenger at yahoo.com> wrote:
>Franz Steinhaeusler wrote:
>>
>> Thank you all for the replies.
>> But I still don't have a solution.
>>
>> Of course with more lines it is possible,
>> but it would be fine to have a "oneliner".
>
>re.sub(r"\s+[\n\r]+", lambda x: x.expand("\g<0>"). \
> lstrip(" \t\f\v"),text).rstrip()
>
>...where "text" is the unsplit block of text with mysterious line-endings.
>
>But I think your code is a lot easier to read. :)
Hello John,
perfect, thank you,
but as you said, this is somehow not so easy to grasp.
(At least for me). :-)
--
Franz Steinhaeusler
More information about the Python-list
mailing list