How to replace characters that don't match regex in TypeScript

1 Answer

0 votes
let str = 'Typescript4*&$%#';
 
str = str.replace(/[^a-zA-Z]/g, '!');
 
console.log(str); 
   
   
   
   
/*
run:
   
"Typescript!!!!!!" 
   
*/

 



answered Apr 15, 2022 by avibootz
...