backslash

Difference between forward slash (/) and backslash (\) in file path

∥☆過路亽.° 提交于 2019-11-26 08:55:19
问题 I was wondering about the difference between \\ and / in file paths. I have noticed that sometimes a path contains / and sometimes it is with \\ . It would be great if anyone can explain when to use \\ and / . 回答1: / is the path separator on Unix and Unix-like systems. Modern Windows can generally use both \ and / interchangeably for filepaths, but Microsoft has advocated for the use of \ as the path separator for decades. This is done for historical reasons that date as far back as the 1970s

Replace “\\\\” with “\\” in a string in C#

左心房为你撑大大i 提交于 2019-11-26 08:51:18
I still don't get how to do this. I saw many posts regarding this, but none of the solutions worked for me. I have a string called "a\\b". The result I need is "a\b". How is this done? I have a text file which has a database connection string pointing to an instance called - Server\DbInstance My aim is to do a string replace in the text file -- replace "Server\DbInstance" with another value, say "10.11.12.13, 1200". So I have: stringToBeReplaced = @"Server\DbInstance"; newString = @"10.11.12.13, 1200"; This is where the problem starts. My stringToBeReplaced will always be "Server\\DbInstance",

How to escape the backslashes and the automatically generated escape character in file path in java

为君一笑 提交于 2019-11-26 08:28:13
问题 I have very small and simple problem but I am not getting solutions on it. Actually I am getting a CSV file path using file chooser. I am entering the data in this csv file in to database using load data local infile query. Suppose my entered file path is \"C:\\title.csv\" When I put this string in to query the you will see the \\t combination in the path. This \\t which is actually part of the file path and not the escape character \'\\t\'. But the java and mysql consider it as escape

How to escape a backslash in R? [duplicate]

孤街浪徒 提交于 2019-11-26 08:24:41
问题 This question already has an answer here: How to escape backslashes in R string 3 answers I\'m working in R and having troubles escaping the backslash. I am using the library stringr . install.packages(\"stringr\", repos=\'http://cran.us.r-project.org\') library(\"stringr\") I would like to do str = str_replace_all(str, \"\\\", \"\") So I tried str = str_replace_all(str, \"\\\\\", \"\") but it won\'t work. What should I do? 回答1: I found a solution that works str = gsub("([\\])","", str) 回答2:

Weird backslash substitution in Ruby

╄→尐↘猪︶ㄣ 提交于 2019-11-26 08:18:21
问题 I don\'t understand this Ruby code: >> puts \'\\\\ <- single backslash\' # \\ <- single backslash >> puts \'\\\\ <- 2x a, because 2 backslashes get replaced\'.sub(/\\\\/, \'aa\') # aa <- 2x a, because two backslashes get replaced so far, all as expected. but if we search for 1 with /\\\\/ , and replace with 2, encoded by \'\\\\\\\\\' , why do we get this: >> puts \'\\\\ <- only 1 ... replace 1 with 2\'.sub(/\\\\/, \'\\\\\\\\\') # \\ <- only 1 backslash, even though we replace 1 with 2 and

So what IS the right direction of the path&#39;s slash (/ or \) under Windows?

倾然丶 夕夏残阳落幕 提交于 2019-11-26 08:02:45
问题 It seems Windows insists on writing a backslash \\ in file paths, whereas .NET\'s URI class writes them with a slash / . Is there any right way, that is accepted even in the most primitive systems? And why is .NET\'s URI showing the other slash compared with the rest of Windows? 回答1: A file path and a URI are different. \ is correct in a Windows file path and / is correct in a URI. So this file path: C:\Documents\Foo translates to this URI: file:///C:/Documents/Foo 回答2: Windows is the bastard

Javascript and backslashes replace

前提是你 提交于 2019-11-26 07:47:53
问题 here is my string: var str = \"This is my \\string\"; This is my code: var replaced = str.replace(\"/\\\\/\", \"\\\\\\\\\"); I can\'t get my output to be: \"This is my \\\\string\" I have tried every combination I can think of for the regular expression and the replacement value. Any help is appreciated! 回答1: Got stumped by this for ages and all the answers kept insisting that the source string needs to already have escaped backslashes in it ... which isn't always the case. Do this .. var

Why are the backslash and semicolon required with the find command&#39;s -exec option?

隐身守侯 提交于 2019-11-26 07:36:09
问题 I have begun to combine different commands in the linux terminal. I am wondering why the backslash and semicolon are required for a command such as: find ./ -name \'blabla\' -exec cp {} ./test \\; when a simple cp command is simply: cp randomfile ./test without the \\; Are they to clearly indicate the end of a command, or is it simply required in the documentation? What is the underlying principle? Thank you! 回答1: The backslash before the semicolon is used, because ; is one of list operators

Escaping backslash in string - javascript

若如初见. 提交于 2019-11-26 06:03:14
问题 I need to show the name of the currently selected file (in <input type=\"file\"> element). Everything is fine, the only problem is I\'m getting this kind of string \"C:\\fakepath \\typog_rules.pdf\" (browset automatically puts this as value for the input element). When I try to split the string by \'\\\' or \'\\\\\' it fails because of unescaped slashes. Attempts to match/replace slashes fails too. Is there a way around this? I need this to work at least in Opera and IE (because in other

using backslash in python (not to escape)

自闭症网瘾萝莉.ら 提交于 2019-11-26 02:38:47
问题 import os path= os.getcwd() final= path +\'\\xulrunner.exe \' + path + \'\\application.ini\' print final I want the out put: c:\\python25\\xulrunner.exe c:\\python25\\application.ini I don\'t want backslash to work as string, i mean don\'t want it to escape or do anything special. But i get an error Invalid \\x escape How can i use a \'\\\' as a \'\\\' and not an escape? 回答1: To answer your question directly, put r in front of the string. final= path + r'\xulrunner.exe ' + path + r'