regular expresson for Unix and Dos Lineendings wanted

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Thu Feb 23 12:41:47 EST 2006


Franz Steinhaeusler wrote:
> On Thu, 23 Feb 2006 13:54:50 +0000, Martin Franklin
> <mfranklin1 at gatwick.westerngeco.slb.com> wrote:
> 
>>>>>> r="erewr    \r\nafjdskl     "
>>> 'erewr    \r\nafjdskl'
>>>
>>> 2) Unix
>>>>>> r="erewr    \nafjdskl     "
>>> 'erewr\nafjdskl'
>> why not use string methods strip, rstrip and lstrip
>>
> 
> because this removes only the last spaces,
>>>> r
> 'erewr    \r\nafjdskl     '
>>>> r.rstrip()
> 'erewr    \r\nafjdskl'
> 
> I want:
> 'erewr\r\nafjdskl'
> 
> or for unix line endings
> 'erewr\nafjdskl'
> 


how about one of these variations

print 'erewr    \r\nafjdskl     '.replace(" ", "")
print 'erewr    \r\nafjdskl     '.strip(" \t")






More information about the Python-list mailing list