Re: regular expresson for Unix and Dos Lineendings wanted

2006-02-27 Thread Franz Steinhaeusler
On 24 Feb 2006 14:12:05 + (GMT), Sion Arrowsmith <[EMAIL PROTECTED]> wrote: >Franz Steinhaeusler <[EMAIL PROTECTED]> wrote: >>On Thu, 23 Feb 2006 13:54:50 +, Martin Franklin >>>why not use string methods strip, rstrip and lstrip >>because this removes only the last spaces, >> [given r = '

Re: regular expresson for Unix and Dos Lineendings wanted

2006-02-24 Thread Franz Steinh�usler
On Fri, 24 Feb 2006 07:21:04 -0500, John Zenger <[EMAIL PROTECTED]> 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]+"

Re: regular expresson for Unix and Dos Lineendings wanted

2006-02-24 Thread Tim Williams (gmail)
On 24/02/06, John Zenger <[EMAIL PROTECTED]> wrote: Franz Steinhaeusler wrote:>> Thank you all for the replies.> But I still don't have a solution.>re.sub(r"\s+[\n\r]+", lambda x: x.expand("\g<0>"). \ lstrip(" \t\f\v"),text).rstrip() But I think your code is a lot easier to read.  :) How about:

Re: regular expresson for Unix and Dos Lineendings wanted

2006-02-24 Thread Sion Arrowsmith
Franz Steinhaeusler <[EMAIL PROTECTED]> wrote: >On Thu, 23 Feb 2006 13:54:50 +, 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() f

Re: regular expresson for Unix and Dos Lineendings wanted

2006-02-24 Thread John Zenger
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 "tex

Re: regular expresson for Unix and Dos Lineendings wanted

2006-02-24 Thread Franz Steinhaeusler
On Fri, 24 Feb 2006 12:36:01 +0100, Franz Steinhaeusler <[EMAIL PROTECTED]> wrote: >if n > 1: if n > 0: (of course) :-) -- Franz Steinhaeusler -- http://mail.python.org/mailman/listinfo/python-list

Re: regular expresson for Unix and Dos Lineendings wanted

2006-02-24 Thread Franz Steinhaeusler
On Thu, 23 Feb 2006 17:41:47 +, Martin Franklin <[EMAIL PROTECTED]> wrote: >Franz Steinhaeusler wrote: >> On Thu, 23 Feb 2006 13:54:50 +, Martin Franklin >> <[EMAIL PROTECTED]> wrote: >> >>> r="erewr\r\nafjdskl " 'erewr\r\nafjdskl' 2) Unix >>> r="erewr

Re: regular expresson for Unix and Dos Lineendings wanted

2006-02-24 Thread Steven D'Aprano
On Thu, 23 Feb 2006 15:13:01 +0100, Franz Steinhaeusler wrote: >>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 l

Re: regular expresson for Unix and Dos Lineendings wanted

2006-02-24 Thread Martin Franklin
Franz Steinhaeusler wrote: > On Thu, 23 Feb 2006 14:46:20 +0100, Franz Steinhaeusler > <[EMAIL PROTECTED]> wrote: > >> Hello, I need a regularexpression, which trims trailing whitespaces. >> >> While with unix line endings, it works; >> but not with Window (Dos) CRLF's: > > Thank you all for the

Re: regular expresson for Unix and Dos Lineendings wanted

2006-02-24 Thread Franz Steinhaeusler
On Thu, 23 Feb 2006 14:46:20 +0100, Franz Steinhaeusler <[EMAIL PROTECTED]> wrote: >Hello, I need a regularexpression, which trims trailing whitespaces. > >While with unix line endings, it works; >but not with Window (Dos) CRLF's: Thank you all for the replies. But I still don't have a solution.

Re: regular expresson for Unix and Dos Lineendings wanted

2006-02-23 Thread John Zenger
How about r"\s+[\n\r]+|\s+$" ? Franz Steinhaeusler wrote: > Hello, I need a regularexpression, which trims trailing whitespaces. > > While with unix line endings, it works; > but not with Window (Dos) CRLF's: > > import re retrailingwhitespace = re.compile('(?<=\S)[ \t]+$', re.MULTILI

Re: regular expresson for Unix and Dos Lineendings wanted

2006-02-23 Thread Martin Franklin
Franz Steinhaeusler wrote: > On Thu, 23 Feb 2006 13:54:50 +, Martin Franklin > <[EMAIL PROTECTED]> wrote: > >> r="erewr\r\nafjdskl " >>> 'erewr\r\nafjdskl' >>> >>> 2) Unix >> r="erewr\nafjdskl " >>> 'erewr\nafjdskl' >> why not use string methods strip, rstrip and ls

Re: regular expresson for Unix and Dos Lineendings wanted

2006-02-23 Thread Franz Steinhaeusler
On Thu, 23 Feb 2006 15:59:54 +0100, Franz Steinhaeusler <[EMAIL PROTECTED]> wrote: >I need it for a file, whose line endings I don't know. > >I wrote for DrPython this script: >(using styled text control and wxPython) and this works, >but I'm looking for a shorter way: ah, sorry, I try to make th

Re: regular expresson for Unix and Dos Lineendings wanted

2006-02-23 Thread Franz Steinhaeusler
On 23 Feb 2006 06:44:36 -0800, "gene tani" <[EMAIL PROTECTED]> wrote: > >gene tani wrote: >> Franz Steinhaeusler wrote: >> > >> > Who can help me (regular expression, which works for both cases). >> >> universal newlines: >> http://www.python.org/doc/2.3.3/whatsnew/node7.html >> http://mail.python

Re: regular expresson for Unix and Dos Lineendings wanted

2006-02-23 Thread gene tani
gene tani wrote: > Franz Steinhaeusler wrote: > > > > Who can help me (regular expression, which works for both cases). > > universal newlines: > http://www.python.org/doc/2.3.3/whatsnew/node7.html > http://mail.python.org/pipermail/python-list/2006-February/324410.html if multiple end-of line ma

Re: regular expresson for Unix and Dos Lineendings wanted

2006-02-23 Thread Franz Steinhaeusler
On Thu, 23 Feb 2006 13:54:50 +, Martin Franklin <[EMAIL PROTECTED]> 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

Re: regular expresson for Unix and Dos Lineendings wanted

2006-02-23 Thread gene tani
Franz Steinhaeusler wrote: > Hello, I need a regularexpression, which trims trailing whitespaces. > > While with unix line endings, it works; > but not with Window (Dos) CRLF's: > > >>> import re > >>> retrailingwhitespace = re.compile('(?<=\S)[ \t]+$', re.MULTILINE) > > 1) Windows > >>> r="erewr

Re: regular expresson for Unix and Dos Lineendings wanted

2006-02-23 Thread Martin Franklin
Franz Steinhaeusler wrote: > Hello, I need a regularexpression, which trims trailing whitespaces. > > While with unix line endings, it works; > but not with Window (Dos) CRLF's: > import re retrailingwhitespace = re.compile('(?<=\S)[ \t]+$', re.MULTILINE) > > 1) Windows r="erewr

regular expresson for Unix and Dos Lineendings wanted

2006-02-23 Thread Franz Steinhaeusler
Hello, I need a regularexpression, which trims trailing whitespaces. While with unix line endings, it works; but not with Window (Dos) CRLF's: >>> import re >>> retrailingwhitespace = re.compile('(?<=\S)[ \t]+$', re.MULTILINE) 1) Windows >>> r="erewr\r\nafjdskl " >>> newtext, n = retrai