backslash

Convering double backslash to single backslash in Python 3

烂漫一生 提交于 2019-11-30 22:51:50
I have a string like so: >>> t '\\u0048\\u0065\\u006c\\u006c\\u006f\\u0020\\u20ac\\u0020\\u00b0' That I made using a function that converts unicode to the representative Python escape sequences. Then, when I want to convert it back, I can't get rid of the double backslash so that it is interpreted as unicode again. How can this be done? >>> t = unicode_encode(" >>> t '\\u0048\\u0065\\u006c\\u006c\\u006f\\u0020\\u20ac\\u0020\\u00b0' >>> print(t) \u0048\u0065\u006c\u006c\u006f\u0020\u20ac\u0020\u00b0 >>> t.replace('\\','X') 'Xu0048Xu0065Xu006cXu006cXu006fXu0020Xu20acXu0020Xu00b0' >>> t.replace('

escaping backslash in java string literal [duplicate]

怎甘沉沦 提交于 2019-11-30 19:33:54
This question already has an answer here: Replacing single '\' with '\\' in Java 6 answers I am using Java for a while and come up with this problem: I use hard-coded paths in windows like "D:\Java-code\JavaProjects\workspace\eypros\src" The problem is that I need to escape the backslash character in order to use it with string. So I manually escape each backslash: "D:\\Java-code\\JavaProjects\\workspace\\eypros\\src" Is there a way to automatically take the unescaped path and return an escaped java string. I am thinking that maybe another container besides java string could do the trick (but

mysql: replace \\ (backslash) in strings

旧城冷巷雨未停 提交于 2019-11-30 19:08:32
I am having the following problem: I have a table T which has a column Name with names. The names have the following structure: A\\B\C You can create on yourself like this: create table T ( Name varchar(10)); insert into T values ('A\\\\B\\C'); select * from T; Now if I do this: select Name from T where Name = 'A\\B\C'; That doesn't work, I need to escape the \ (backslash): select Name from T where Name = 'A\\\\B\\C'; Fine. But how do I do this automatically to a string Name? Something like the following won't do it: select replace('A\\B\C', '\\', '\\\\'); I get: A\\\BC Any suggestions? Many

Convering double backslash to single backslash in Python 3

我与影子孤独终老i 提交于 2019-11-30 17:41:42
问题 I have a string like so: >>> t '\\u0048\\u0065\\u006c\\u006c\\u006f\\u0020\\u20ac\\u0020\\u00b0' That I made using a function that converts unicode to the representative Python escape sequences. Then, when I want to convert it back, I can't get rid of the double backslash so that it is interpreted as unicode again. How can this be done? >>> t = unicode_encode(" >>> t '\\u0048\\u0065\\u006c\\u006c\\u006f\\u0020\\u20ac\\u0020\\u00b0' >>> print(t) \u0048\u0065\u006c\u006c\u006f\u0020\u20ac\u0020

C# verbatim string literal not working. Very Strange backslash always double

∥☆過路亽.° 提交于 2019-11-30 09:31:20
问题 I've tried for quite a long time to figure out whats going on but I've not found anything anywhere that someone besides me has ran into this issue. I'm simply trying to hard code a path into a string. Easy stuff. Well for some reason string fullPathSourceFile = @"c:\SQLSOURCE.txt"; is evaluating to c:\\SQLSOURCE.txt I've tried everything to evaluated it to a single backslash remove the double quotes and it wont work. I even tried Replace(@"\\", @"\") and it has no affect. Anyone have any idea

How to handle backslash character in PowerShell -replace string operations?

 ̄綄美尐妖づ 提交于 2019-11-30 09:10:31
问题 I am using -replace to change a path from source to destination. However I am not sure how to handle the \ character. For example: $source = "\\somedir" $dest = "\\anotherdir" $test = "\\somedir\somefile" $destfile = $test -replace $source, $dest After this operation, $destfile is set to "\\\anotherdir\somefile" What is the correct way to do this to avoid the triple backslash in the result? 回答1: Try the following: $source = "\\\\somedir" You were only matching 1 backslash when replacing,

Java regular expression value.split(“\\.”), “the back slash dot” divides by character?

独自空忆成欢 提交于 2019-11-30 06:23:14
问题 From what I understand, the backslash dot ( \. ) means one character of any character? So because backslash is an escape, it should be backslash backslash dot ( "\\." ) What does this do to a string? I just saw this in an existing code I am working on. From what I understand, it will split the string into individual characters. Why do this instead of String.toCharArray() . So this splits the string to an array of string which contains only one char for each string in the array? 回答1: My guess

escaping backslash in java string literal [duplicate]

这一生的挚爱 提交于 2019-11-30 03:42:38
问题 This question already has answers here : Replacing single '\' with '\\' in Java (6 answers) Closed 4 years ago . I am using Java for a while and come up with this problem: I use hard-coded paths in windows like "D:\Java-code\JavaProjects\workspace\eypros\src" The problem is that I need to escape the backslash character in order to use it with string. So I manually escape each backslash: "D:\\Java-code\\JavaProjects\\workspace\\eypros\\src" Is there a way to automatically take the unescaped

mysql: replace \ (backslash) in strings

寵の児 提交于 2019-11-30 02:46:15
问题 I am having the following problem: I have a table T which has a column Name with names. The names have the following structure: A\\B\C You can create on yourself like this: create table T ( Name varchar(10)); insert into T values ('A\\\\B\\C'); select * from T; Now if I do this: select Name from T where Name = 'A\\B\C'; That doesn't work, I need to escape the \ (backslash): select Name from T where Name = 'A\\\\B\\C'; Fine. But how do I do this automatically to a string Name? Something like

Windows shell string operations (changing backslash to slash)

回眸只為那壹抹淺笑 提交于 2019-11-30 00:06:42
I need to write a script that takes the current path (%~dp0), transforms backslashes into forward slashes and passes it further to some command. Due to the environment I'm working in the only option that I have is windows shell (not Powershell where the issue would not a problem). Is it even possible to do that? The set command has a substitution feature: set a=C:\test\dir set a=%a:\=/% echo %a% Results in: C:/test/dir 来源: https://stackoverflow.com/questions/2903416/windows-shell-string-operations-changing-backslash-to-slash