Answers for "rust replace characters"

2

rust replace characters

let s:String = "Hello, world!".chars()
    .map(|x| match x { 
        '!' => '?', 
        'A'..='Z' => 'X', 
        'a'..='z' => 'x',
        _ => x
    }).collect();
println!("{}", s);// Xxxxx, xxxxx?
// Avoids using Regex
Posted by: Guest on February-21-2021

Browse Popular Code Answers by Language