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

1 Answer

0 votes
const str = "8javascript rust java 123 c &c++.";

const result = str.replace(/[^A-Za-z]/g, "").length;

console.log(result);


/*
run:

20

*/

 



answered Sep 16, 2024 by avibootz
...