Help me on Backspace please

Craig Radcliffe chradcliffe at
Thu Jun 26 23:58:26 CEST 2008

Something like this might do the trick:

import re
f  = open("file.txt")
old_text = f.readlines()
new_text = [re.sub(r'.\b', '', i) for i in old_text]
f = open("file_modified.txt", "w")

I don't know how necessary the separate read and writes are, but it'll be
good for a start. At any rate, you'll want to look at the

On Thu, Jun 26, 2008 at 16:32, <cakomo at> wrote:

> Hi
> I am a beginner on Python and have a problem..
> I have text file and reading it line by line and there are backspace
> characters in it like '\b' or anything you want like "#".  I want to
> replace these chars. with Backspace action. I mean deleting the
> previous char. and the \b char also. and writing all cleaned text to a
> file again.
> How can I do that.
> Thanks..
> --
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list