regular expresson for Unix and Dos Lineendings wanted

Franz Steinhaeusler franz.steinhaeusler at gmx.at
Mon Feb 27 04:46:48 EST 2006


On 24 Feb 2006 14:12:05 +0000 (GMT), Sion Arrowsmith
<siona at chiark.greenend.org.uk> wrote:

>Franz Steinhaeusler  <franz.steinhaeusler at gmx.at> wrote:
>>On Thu, 23 Feb 2006 13:54:50 +0000, Martin Franklin
>>>why not use string methods strip, rstrip and lstrip
>>because this removes only the last spaces,
>> [given r = 'erewr    \r\nafjdskl     ']
>>I want:
>>'erewr\r\nafjdskl'
>
>os.linesep.join(l.rstrip() for l in r.split(os.linesep))

Hello Sion,

thank you, your solution, I like most!!
(it is clean und one don't have to use re's).
-- 
Franz Steinhaeusler



More information about the Python-list mailing list