regular expresson for Unix and Dos Lineendings wanted
John Zenger
john_zenger at yahoo.com
Fri Feb 24 07:21:04 EST 2006
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. :)
More information about the Python-list
mailing list