Created
August 22, 2017 03:49
-
-
Save 92hackers/bb777c40f81b80a026ed84077bd9da52 to your computer and use it in GitHub Desktop.
javascript deals with back slach, useful when involved Windows OS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'C:\Users\Administrator/Desktop/7-42.pdf' is wrong. | |
should be 'C:\\Users\\Administrator/Desktop/7-42.pdf' | |
because \ is preserved to escape character. | |
const str = 'C:\\Users\\Administrator/Desktop/7-42.pdf' | |
str.replace(/\//g, '\\') | |
// => 'C:\\Users\\Administrator\\Desktop\\7-42.pdf' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment