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
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
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/
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'
[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
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
[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
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.
[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
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',
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
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
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
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)
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
15 matches
Mail list logo