如何在R
中将单反斜杠\
转换为双反斜杠\\
例如:
\\\server\\folder1\\sub_folder -> "\\\\\\\server\\\\folder1\\\\sub_folder"
答案 0 :(得分:1)
# What your input should look like.
txt <- "\\\\server\\folder1\\sub_folder"
cat(txt) # prints \\server\folder1\sub_folder
# Replacing the backslashes for double backslashes.
txtNew <- gsub("\\", "\\\\", txt, fixed = TRUE)
cat(txtNew) # prints \\\\server\\folder1\\sub_folder