i have a string like the following
var string1 = " folder\\subfolder1\\subfolder2 "
and i want to replace the "\\" with "/" with string1.replace in order to be
var string2 = "folder/subfolder1/subfolder2"
I tried
var rep = path.replace("\\", "/");
but is not working. Any help ?
你需要全局地做,例如使用regexp文字和g
标志;
var rep = path.replace(/\\/g, "/");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.