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 = '
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]+"
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:
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
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
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
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
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
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
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.
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
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
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
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
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
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
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
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
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
19 matches
Mail list logo