- replacen
String replace limited times
examples/strings/replacen/src/main.rs
fn main() { let text = String::from("Black cat, brown cat, many cats and a dog"); println!("{text}"); let new = text.replacen("cat", "mouse", 2); println!("{new}"); println!("{text}"); }
Black cat, brown cat, many cats and a dog Black mouse, brown mouse, many cats and a dog Black cat, brown cat, many cats and a dog