Tutorial by Examples

Regular expression support for tust is provided by the regex crate, add it to your Cargo.toml: [dependencies] regex = "0.1" The main interface of the regex crate is regex::Regex: extern crate regex; use regex::Regex; fn main() { //"r" stands for "raw" str...
extern crate regex; use regex::Regex; fn main() { let rg = Regex::new(r"was (\d+)").unwrap(); // Regex::captures returns Option<Captures>, // first element is the full match and others // are capture groups match rg.captures("The year was 2016")...
extern crate regex; use regex::Regex; fn main() { let rg = Regex::new(r"(\d+)").unwrap(); // Regex::replace replaces first match // from it's first argument with the second argument // => Some string with numbers (not really) rg.replace("Some string ...

Page 1 of 1