How to count the number of characters in a string without spaces and special characters in TypeScript

1 Answer

0 votes
const str = "8typescript rust@go java 123 c &c++.";
 
const result = str.replace(/[^A-Za-z]/g, "").length;
 
console.log(result);

 
 
/*
run:
 
22
 
*/

 



answered Sep 16, 2024 by avibootz
...