473,765 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I express a backslash in a string?

>>"'"
"'"
>>"\'"
"'"
>>"\\'"
"\\'"
>>"\\\'"
"\\'"
>>>
This is quite different than any other language
that I am used to. Normally, a double backslash
takes away the special meaning of the last backslash,
and so you are left with a single backslash.

How do I express the single backslash?

Thanks,

Tobiah

--
Posted via a free Usenet account from http://www.teranews.com

Aug 22 '07 #1
2 2179
Tobiah wrote:
>>>"'"
"'"
>>>"\'"
"'"
>>>"\\'"
"\\'"
>>>"\\\'"
"\\'"
>>>>

This is quite different than any other language
that I am used to. Normally, a double backslash
takes away the special meaning of the last backslash,
and so you are left with a single backslash.

How do I express the single backslash?

Thanks,

Tobiah
A little more looking, and I see:

>>"\\'"
"\\'"
>>len("\\'")
2
>>>

So it was just the console representation that was fooling
me into thinking that I had a double backslash.

--
Posted via a free Usenet account from http://www.teranews.com

Aug 22 '07 #2
On Aug 22, 1:19 pm, Tobiah <t...@tobiah.or gwrote:
>"'"
"'"
>"\'"
"'"
>"\\'"
"\\'"
>"\\\'"
"\\'"

This is quite different than any other language
that I am used to. Normally, a double backslash
takes away the special meaning of the last backslash,
and so you are left with a single backslash.

How do I express the single backslash?

Thanks,

Tobiah
It IS a single backslash - the interpreter in interactive mode
displays the string literal (escaped) version of what you entered,
which is, well, what you entered. If you print it instead, you'll see
the actual string value.
>>'\\'
'\\'
>>print '\\'
\

Fred

Aug 22 '07 #3

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

Similar topics

3
15875
by: Vincent Texier | last post by:
Hello, I want to send 3 chars in hexa code to the serial port. So I type in a tkinter entry : "\x20\x01\x21" The string is set in a StringVar(). When I read the stringVar, I get : "\\x20\\x01\\x21"
3
22234
by: Terry Asher | last post by:
The following script does NOT escape the Apostrophe. Meaning when you mouseover the image the Alt tag says this: DMACC, It and then it stops. <SCRIPT Language="JavaScript"> var pos = "DMACC, It\'s the Smart Thing to Do."; document.write("<img name=img5 id=img5 src='/homepage/dmaccstudent" + Math.floor(Math.random() *20) + ".jpg' WIDTH=145 HEIGHT=230 border=0 ALT='"+pos+"'>"); </SCRIPT>
6
3192
by: John Salerno | last post by:
I have this: subdomain = raw_input('Enter subdomain name: ') path = r'C:\Documents and Settings\John Salerno\My Documents\My Webs\1and1\johnjsalerno.com\' + subdomain Obviously the single backslash at the end of 'path' will cause a problem, and escaping it with a backslash seems to fix this problem, but how does escaping work when I already have it as a raw string? When I
2
3245
by: John Dann | last post by:
I guess there must be some convention or Windows specification for whether the backslash immediately preceding the file name in a full path string to a file is formally part of the path string or of the file name. I suppose the options are: 1. Part of the path string, ie all returned path strings should have a trailing backslash. 2. Part of the file name, ie all file names should start with a backslash.
8
4367
by: Wijaya Edward | last post by:
Hi all, I was trying to split a string that represent chinese characters below: ??? But why the split function here doesn't seem
5
13848
by: shalini jain | last post by:
Hi, I want to know how to use split function to split the string based on backslash(\). Actually backslash is appearing at the end of the string. and i want to remove it. so if anyone could guide me as to what will be the syntax for removing backslash(\) from the string??
3
23011
by: Stef Mientki | last post by:
It looks like sometimes a single backslash is replaced by a double backslash, but sometimes it's not ??? See the error message below, the first backslash is somewhere (not explicitly in my code) replaced, but the second is not ??? Is it in general better to use double backslash in filepaths ? thanks, Stef Mientki
5
15689
by: vlsidesign | last post by:
The printf function returns "warning: unknown escape sequence: \040" for a backslash-space combination. If the ascii decimal number for space is 32 and the backslash is 92, why this particular number 040? Is it a decimal number from the ASCII code chart? (compiling using gcc on SunOS 5.8, Sparc, Ultra-80) Just curious. Thanks.
1
1597
by: Dravidan | last post by:
I am trying to read some byte data as a string then using a library to convert them a code: My table contains: \x00\x00,0000 \x01\x00,0000 .......
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9404
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10164
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9835
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8833
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5277
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.