js & replaceAll
js & replaceAll
https://caniuse.com/#search=replaceAll
' hello world '.replaceAll(/\s/gi, `🚀`);
// "🚀hello🚀world🚀"
' hello world '.replace(/\s/gi, `🚀`);
// "🚀hello🚀world🚀"
https://zzk.cnblogs.com/my/s/blogpost-p?Keywords=replaceAll
function count(str = 'hello world') {
if(``.replaceAll) {
str.replaceAll(/\s/ig, ``);
} else {
str.replace(/\s/ig, ``);
}
}
empty spaces / white spaces
replace all spaces in js
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
refs
white space
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Character_Classes
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Cheatsheet
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/13554958.html
未经授权禁止转载,违者必究!