

Task

   match a string against a regular expression
   substitute part of a string using a regular expression


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