Re: simple string backspace question



vedrandekovic@xxxxxxxxxxxxxx wrote:

On 31 srp, 12:03, ra...@xxxxxxx (Lawrence Oluyede) wrote:
<vedrandeko...@xxxxxxxxxxxxxx> wrote:
If you mean on operating system then unfortunately Windows XP.

I don't know for sure but maybe it doesn't support all ASCII escapes
codes.

Why do you care about \b anyway :-) ?

--
Lawrence, oluyede.org - neropercaso.it
"It is difficult to get a man to understand
something when his salary depends on not
understanding it" - Upton Sinclair

Hi,

I need this inevitable for my "programming language", for code
indentation. I don't know how to write script with module tokenize
for code indentation.

Still not giving up reinventing the wheel? You should take some lessons on
syntax analysis before attempting this. But I know this words won't be
heard...

So, to your actual problem: that backspace is removing a character is
something an editor or a terminal do, because they interpret the backspace.
You wouldn't expect the string "<font color="blue">foo</font>" to be
rendered blue by magic as well, wouldn't you?

So what you need to do is: search the string for backspaces, and remove the
BS as well as the character before. Something along these lines (untested):

teststring = "abc\bcde\b"

while teststring.find("\b") > -1:
pos = teststring.find("\b")
teststring = teststring[:pos-1] + teststring[pos+1:]


Diez
.



Relevant Pages

  • Re: simple string backspace question
    ... Should this character "\b" (backspace) in this text return this: ... Lawrence, oluyede.org - neropercaso.it ... understanding it" - Upton Sinclair ...
    (comp.lang.python)
  • Re: Great SWT Program
    ... As have I -- but then I know control-U as the line kill character. ... Certainly not with anything obvious like backspace or the ... usually worked in the pico editor on these systems (which was the only ...
    (comp.lang.java.programmer)
  • Re: Odd character appearing in headers (prior threads noted)
    ... To add to my earler comments, the backspace (ascii 8) character is used as a placeholder for a graphic so, perhaps, the actual graphic has somehow got corrupted or deleted. ...
    (microsoft.public.word.docmanagement)
  • Re: hello world
    ... You're confusing the effect of pressing the Backspace key on your console ... on a console using or emulating a glass TTY ... effectively erasing the last character typed before BS. ... Dan Pop ...
    (comp.lang.c)
  • Re: Great SWT Program
    ... to explain why backspace in emacs i-search really Does The Right Thing. ... cr character, but its interpretation depends on the input mode. ... To match an enter in the target text you type ...
    (comp.lang.java.programmer)