How to count the number of characters in a string without spaces and special characters in Node.js

1 Answer

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

 
 
/*
run:
 
16
 
*/
 

 



answered Sep 16, 2024 by avibootz
...