Re: deleting texts between patterns

2006-06-04 Thread Baoqiu Cui
John Machin [EMAIL PROTECTED] writes: Uh-oh. Try this: pat = re.compile('(?=abc\n).*?(?=xyz\n)', re.DOTALL) re.sub(pat, '', linestr) 'blahfubarabc\nxyz\nxyzzy' This regexp still has a problem. It may remove the lines between two lines like 'aaabc' and 'xxxyz' (and also removes the first

Re: deleting texts between patterns

2006-06-04 Thread John Machin
On 5/06/2006 2:51 AM, Baoqiu Cui wrote: John Machin [EMAIL PROTECTED] writes: Uh-oh. Try this: pat = re.compile('(?=abc\n).*?(?=xyz\n)', re.DOTALL) re.sub(pat, '', linestr) 'blahfubarabc\nxyz\nxyzzy' This regexp still has a problem. It may remove the lines between two lines like

Re: deleting texts between patterns

2006-05-19 Thread John Savage
Tim Chase [EMAIL PROTECTED] writes: I wish to delete lines that are in between 'abc' and 'xyz' and print the rest of the lines. Which is the best way to do it? sed -n -e'1,/abc/p' -e'/xyz/,$p' file.txt which is pretty straight-forward. While it looks neat, it will not work when /abc/

deleting texts between patterns

2006-05-12 Thread micklee74
hi say i have a text file line1 line2 line3 line4 line5 line6 abc line8 ---to be delete line9 ---to be delete line10 ---to be delete line11 ---to be delete line12 ---to be delete line13 ---to be delete xyz line15 line16 line17 line18 I wish to delete lines that are in between 'abc' and 'xyz'

Re: deleting texts between patterns

2006-05-12 Thread Ravi Teja
[EMAIL PROTECTED] wrote: hi say i have a text file line1 line2 line3 line4 line5 line6 abc line8 ---to be delete line9 ---to be delete line10 ---to be delete line11 ---to be delete line12 ---to be delete line13 ---to be delete xyz line15 line16 line17 line18 I wish to

Re: deleting texts between patterns

2006-05-12 Thread Duncan Booth
wrote: hi say i have a text file line1 line2 line3 line4 line5 line6 abc line8 ---to be delete line9 ---to be delete line10 ---to be delete line11 ---to be delete line12 ---to be delete line13 ---to be delete xyz line15 line16 line17 line18 I wish to delete lines

Re: deleting texts between patterns

2006-05-12 Thread Fredrik Lundh
[EMAIL PROTECTED] skrev i meddelandet news:[EMAIL PROTECTED] hi say i have a text file line1 line2 line3 line4 line5 line6 abc line8 ---to be delete line9 ---to be delete line10 ---to be delete line11 ---to be delete line12 ---to be delete line13 ---to be delete xyz line15

Re: deleting texts between patterns

2006-05-12 Thread John Machin
On 12/05/2006 6:11 PM, Ravi Teja wrote: [EMAIL PROTECTED] wrote: hi say i have a text file line1 [snip] line6 abc line8 ---to be delete [snip] line13 ---to be delete xyz line15 [snip] line18 I wish to delete lines that are in between 'abc' and 'xyz' and print the rest of the lines.

Re: deleting texts between patterns

2006-05-12 Thread bruno at modulix
[EMAIL PROTECTED] wrote: hi say i have a text file line1 line2 line3 line4 line5 line6 abc line8 ---to be delete line9 ---to be delete line10 ---to be delete line11 ---to be delete line12 ---to be delete line13 ---to be delete xyz line15 line16 line17 line18 I wish to

Re: deleting texts between patterns

2006-05-12 Thread bruno at modulix
bruno at modulix wrote: [EMAIL PROTECTED] wrote: (snip) Don't know if it's better for your actual use case, but this avoids reading up the whole file: def skip(iterable, skipfrom, skipuntil): example usage : f = open(/path/to/my/file.txt) for line in skip_print(f, 'abc',

Re: deleting texts between patterns

2006-05-12 Thread bruno at modulix
Fredrik Lundh wrote: (snip) to print to a file instead of stdout, just replace the print line with a f.write call. Or redirect stdout to a file when calling the program !-) -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL

Re: deleting texts between patterns

2006-05-12 Thread Tim Chase
I wish to delete lines that are in between 'abc' and 'xyz' and print the rest of the lines. Which is the best way to do it? While this *is* the python list, you don't specify whether this is the end goal, or whether it's part of a larger program. If it *is* the end goal (namely, you just want

[OT] Unix Tools (was: deleting texts between patterns)

2006-05-12 Thread Dan Sommers
On Fri, 12 May 2006 07:29:54 -0500, Tim Chase [EMAIL PROTECTED] wrote: I wish to delete lines that are in between 'abc' and 'xyz' and print the rest of the lines. Which is the best way to do it? While this *is* the python list, you don't specify whether this is the end goal, or whether it's

Re: [OT] Unix Tools (was: deleting texts between patterns)

2006-05-12 Thread Edward Elliott
Dan Sommers wrote: Or even awk '/abc/,/xyz/' file.txt Excluding the abc and xyz lines is left as an exercise to the interested reader. Once again, us completely disinterested readers get the short end of the stick. :) -- Edward Elliott UC Berkeley School of Law (Boalt Hall)

Re: deleting texts between patterns

2006-05-12 Thread Ravi Teja
I don't think that's what you really meant ^ 2 Right! That was very buggy. That's what I get for posting past 1 AM :-(. -- http://mail.python.org/mailman/listinfo/python-list