Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
路径就像“C:/TEST/”,我想将它转换为“C:\ TEST \”,我搜索了很多并且很难做到。
\表示转义序列的开始,因此必须用另一个\.
\
要全局替换,您需要使用正则表达式,这需要更多的字符转义:
> 'C:/TEST/'.replace(/\//g, '\\') "C:\TEST\"
"C:/TEST/".replace(/\//g, '\\')