How to extract only the digits from a string in Node.js

1 Answer

0 votes
const str = '824 javascript 9001 c c++ 17';
 
const digits = str.replace(/[^0-9]/g, "");

console.log(digits); 
 
   
   
   
   
/*
run:
   
824900117
   
*/

 



answered May 4, 2022 by avibootz
...