I want to replace number with special characters and numbers from a string.
Ex."3 6 8 47" and expected output is " $3 $6 $8 $47 ".
I can use replace method and implemented like below:
var content = "1 3 4";
content = content.replace(/1/g, " $1 ");
console.log(content); // $1 3 4
Here, I can replace only one number and I do want to write for each number.
Or I can use split method and add $ to each items of array and join.
I'm looking for some generic replace method to achieve this.