469,275 Members | 1,825 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

Backslash substitutions

Hello,

How would you perform backslash substitution in a string, just like the
Python parser does?

Example:
---
s = "\\n"
print s \n print ???(s)
---
where '???' is a function that I wasn't able to find.

Just in case, another example:
--- s = "\\\\A\\tB"
print s \\A\tB print ???(s) \A B

---

Thank you.
Jul 18 '05 #1
1 1216
Vivien Mallet wrote:
How would you perform backslash substitution in a string, just like the
Python parser does?

"\\\\A\\tB".decode("string_escape") '\\A\tB' _.encode("string_escape") # back again

'\\\\A\\tB'

Peter

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Tony Eva | last post: by
5 posts views Thread by Aloysio Figueiredo | last post: by
8 posts views Thread by abhishek | last post: by
3 posts views Thread by Stef Mientki | last post: by
2 posts views Thread by Tobiah | last post: by
4 posts views Thread by Razzbar | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.