Javascript String replace all words

Description

Javascript String replace all words

let re = /\\d/;/*from w w w.  ja  v  a 2 s  .  c om*/
let pattern = "\\d{4}";
let str = "I want 1111 to find 3334 certain 5343 things 8484";
let pattern2 = pattern.replace(re, "\\D");
console.log(pattern2);

let re3 = new RegExp(pattern2, "g");
let str2 = str.replace(re3, "****");
console.log(str2);



PreviousNext

Related