472,971 Members | 1,849 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,971 software developers and data experts.

simple string backspace question

Hello,

I have one simple string, backspace character question.Here is my
example:
>>text="Hello\bworld"
print text
"HelloBSworld"

Should this character "\b" (backspace) in this text return this:
"Helloworld"?

Regards,
Vedran

Jul 31 '07 #1
6 5961
<ve***********@v-programs.comwrote:
>text="Hello\bworld"
print text
"HelloBSworld"

Should this character "\b" (backspace) in this text return this:
"Helloworld"?
rhymes@groove ~ % python Python
2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>text="Hello\bworld"
print text
Hellworld

What system are u using?

--
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
Jul 31 '07 #2
On 31 srp, 11:44, vedrandeko...@v-programs.com wrote:
Hello,

I have one simple string, backspace character question.Here is my
example:
>text="Hello\bworld"
print text

"HelloBSworld"

Should this character "\b" (backspace) in this text return this:
"Helloworld"?

Regards,
Vedran
Hi,

If you mean on operating system then unfortunately Windows XP.

Regards,
Vedran

Jul 31 '07 #3
<ve***********@v-programs.comwrote:
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
Jul 31 '07 #4
On 31 srp, 12:03, ra...@dot.com (Lawrence Oluyede) wrote:
<vedrandeko...@v-programs.comwrote:
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.

Regards,
Vedran

Jul 31 '07 #5
ve***********@v-programs.com wrote:
On 31 srp, 12:03, ra...@dot.com (Lawrence Oluyede) wrote:
><vedrandeko...@v-programs.comwrote:
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
Jul 31 '07 #6
On Jul 31, 10:33 pm, Dustan <DustanGro...@gmail.comwrote:
On Jul 31, 7:17 am, John Machin <sjmac...@lexicon.netwrote:
On Jul 31, 8:01 pm, vedrandeko...@v-programs.com wrote:
On 31 srp, 11:44, vedrandeko...@v-programs.com wrote:
Hello,
I have one simple string, backspace character question.Here is my
example:
>>text="Hello\bworld"
>>print text
"HelloBSworld"
Should this character "\b" (backspace) in this text return this:
"Helloworld"?
Regards,
Vedran
Hi,
If you mean on operating system then unfortunately Windows XP.
Point (1) Works on Windows XP for me:
C:\junk>ver
Microsoft Windows XP [Version 5.1.2600]
C:\junk>\python25\python
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>text = "Hello\bworld"
>>print text
Hellworld
or, for mild amusement:
>>import sys, time
>>for x in xrange(100):
... sys.stdout.write("|/-\\"[x & 3] + "\b")
... time.sleep(0.1)
...

Now try it on IDLE.
So the OP should have been slagging off at PythonWin and IDLE, not at
Windows.
Jul 31 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: da Vinci | last post by:
OK, this has got to be a simple one and yet I cannot find the answer in my textbook. How can I get a simple pause after an output line, that simply waits for any key to be pressed to move on? ...
11
by: Lord Khaos | last post by:
If I am trying to find an expression, foo, I can do something like this: rExp = /foo/gi; if(results.search(rExp) > -1){ and all work fine. however, if I want my search term to be a...
6
by: Sender | last post by:
HI folks. I was wondering. In using forms with javascript, I noticed that you can create a new line in a multiline text box using the escape code '\r'. Does anyone know where I could find a list of...
1
by: haxmya | last post by:
Ok, made an explorer toolbar (band Object) with a textbox on it. Everything works great....except that the backspace button doesn't actually backspace when you're in the textbox. Shift-backspace...
7
by: Bruce Duncan | last post by:
I know this should be simple...but for some reason my brain isn't working. I want my users to enter a the date in three seperate boxes. After the users enters in two digits for the month I want...
6
by: Robert Nurse | last post by:
Hi, Is it at all possible to capture and suppress the backspace key when focus is not on a form edit control? Basically, while the page is loading I don't want the user pressing the backspace...
9
by: Henke | last post by:
Hi! Is there a simple way to check if a string entered in a text box is a valid integer? Thanks in advance! /Henke
9
by: Bernie Yaeger | last post by:
I'm trying to control the textbox keypress event to deal with a "." such that it disallows a second "." and no characters after 2 numbers beyond the "." (thus a currency value). I have no problem...
4
by: Dr_Locke_Z2A | last post by:
I was talking to my uncle the other day about getting into programming games and he recommended to start teaching myself with really simple games, like Pong simple. So I looked on google and...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.