To capitalize a string in Rust, you have two primary routes.
Rust gives you a few ways to piece texts together.
Before the .to_lowercase() method, you might have seen Rustaceans using .to_ascii_lowercase() for the same task, which only affected ASCII characters.
.to_lowercase()
.to_ascii_lowercase()
In Rust, we can use the replace method from the String type or regex for more complex patterns.
replace
String
Let’s get our hands dirty with Rust.
Rust gives you len() for straight-up length.
len()
In Rust, we use the format! macro.
format!
Sometimes you’ve got a string with mixed quotes, like this.
Searching and replacing text has been around since early text editors emerged.
Rust’s regex library is a go-to for working with regular expressions.
regex