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 121 views
1 answer 128 views
1 answer 129 views
1 answer 122 views
1 answer 141 views
1 answer 119 views
1 answer 118 views
...