我正在寻找可与javascript的string.replace函数一起使用的正则表达式,以用空格以外的新字符替换字符串中的所有字符。
例如,以下字符串:“一串单词和空格”
将成为以下字符串:“####### ## ##### ### ######”
在\S
全球范围内进行正则表达式替换:
var input = "A string of words and spaces";
var output = input.replace(/\S/g, "#");
console.log(input + "\n" + output);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句