How to replace all numbers in a string with Node.js

2 Answers

0 votes
let str = "node.js 17.4 c++ 20 php 8 java 17";

str = str.replace(/[0-9]/g, '*');

console.log(str); 






/*
run:

node.js **.* c++ ** php * java **

*/

 



answered Feb 12, 2022 by avibootz
0 votes
let str = "node.js 17.4 c++ 20 php 8 java 17";
 
str = str.replace(/\d/g, '*'); 
 
console.log(str); 
 
 
 
 
 
 
/*
run:
 
node.js **.* c++ ** php * java **
 
*/

 



answered Feb 13, 2022 by avibootz

Related questions

1 answer 142 views
1 answer 114 views
1 answer 121 views
1 answer 136 views
2 answers 283 views
3 answers 352 views
3 answers 205 views
...