How to remove all digits from a string using regex in JavaScript

1 Answer

0 votes
const s = "abs322kl59po@$d0057qn8";

// 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:
   
absklpo@$dqn
 
*/

 



answered Dec 10, 2024 by avibootz

Related questions

1 answer 222 views
1 answer 221 views
1 answer 215 views
1 answer 230 views
1 answer 233 views
1 answer 211 views
1 answer 225 views
...