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

1 Answer

0 votes
fn main() {
    let s = "8rust! c# @ java# 123 c &c++.";
    
    let result = s.chars().filter(|c| c.is_alphabetic()).count();
    
    println!("{}", result);
}


  
/*
run:

11

*/

 



answered Sep 16, 2024 by avibootz
...