How to keep only small letters and numbers and remove other characters from string in TypeScript

1 Answer

0 votes
let s: string = 'SL3-0/RQ@a{90}fp#6K$$cCKQ^8htMNPamn1vlWMhJy';
 
s = s.replace(/[^a-z0-9]+/g, "");
 
console.log(s);
 
 
 
/*
run:
 
"30a90fp6c8htamn1vlhy" 
 
*/


 



answered Mar 26, 2025 by avibootz
...