I need to replace all occurrences of // with . in a string, but the solution I have now replaces each slash with "."
So Folder//file//name becomes Folder..file..name
It's a Node.js app and it didn't like replaceAll..
Code :
filename = filename.replace(/\//g, ".");
Group the experession:
const path = 'Folder//file//name'; console.log(path.replace(/(\\/\\/)/gm, "."));
尝试这个
filename.replace(/\/\//g, ".");
filename = filename.replace(/\//g, ".");
This code replaces all one /
s with .
but if you want to replace double slashes //
with one dot .
, you should use:
filename = filename.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.