所以这就是我想要做的事情:
var string = "/something/12/anything/234/xyz";
//i want to get this to result out of this ==> "/something/secret/anything/secret/xyz
基本上用一些字符串替换所有数字" secret"。
答案 0 :(得分:1)
使用正则表达式/\d+/g
替换
var str = "/something/12/anything/234/xyz";
console.log(str.replace(/\d+/g, "secret"));