RosettaCodeData/Task/Regular-expressions/Rust/regular-expressions.rs
2024-10-16 18:07:41 -07:00

11 lines
233 B
Rust

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 "));
}