How to remove all digits from a string using regex in Node.js

1 Answer

0 votes
const s = "abxz322kl519po@$d0057qnm88";

// Create a regular expression to match digits
const digitsRegex = /[0-9]/g;

// Use String.prototype.replace to replace digit characters with an empty string
const result = s.replace(digitsRegex, "");

console.log(result);


   
   
/*
run:
   
abxzklpo@$dqnm
 
*/
 

 



answered Dec 10, 2024 by avibootz
...