RosettaCodeData/Task/Regular-expressions/Rust/regular-expressions.rust

12 lines
233 B
Plaintext

use regex::Regex;
fn main() {
let s = "I am a string";
if Regex::new("string$").unwrap().is_match(s) {
println!("Ends with string.");
}
println!("{}", Regex::new(" a ").unwrap().replace(s, " another "));
}