Javascript String Replace all digits

Description

Javascript String Replace all digits


// search for \d/*from ww  w  .  j a v  a2s.c o m*/
let re = /\\d/;
let pattern = "\\d{4}";
let str = "I want 1111 to find 3334 certain 5343 things 8484";
let re2 = new RegExp(pattern, "g");
let str1 = str.replace(re2, "****");
console.log(str1);



PreviousNext

Related