How to delete a line with re?

John Machin sjmachin at lexicon.net
Mon Aug 18 21:13:43 CEST 2008


On Aug 18, 10:56 pm, Edwin.Mad... at VerizonWireless.com wrote:
> running this snippet, is blanking out ^abdc$.. what is the issue ?
> abcd
> efg
> hijk
> lmn
> $
>
> efg
> hijk
> lmn
>

The OP said he wanted to delete the line with abc [sic]. He showed no
interest in "blanking out ^abdc$. [sic]". The given snippet deletes
the abcd but doesn't delete the newline. However the OP gave no clue
as to what the actual problem was -- he may have had a trailing space
or two after the abcd in the input line; this would not be matched by
the pattern and so nothing would be deleted.



More information about the Python-list mailing list