xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

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

https://stackoverflow.com/questions/22165543/what-is-the-regular-expression-to-replace-white-space-with-a-specified-character

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 发布文章使用:只允许注册用户才可以访问!


posted @ 2020-08-24 17:07  xgqfrms  阅读(216)  评论(4编辑  收藏  举报