1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
extern crate regex;
use regex::Captures;

mod util;

pub fn matcher<'a>(pattern: &'a str, url: &'a str) -> Result<Captures<'a>, bool> {

    let expr = util::expression(pattern);
    let re = util::regexp(&expr);

    if re.is_match(url) {
        Ok(re.captures(url).unwrap())
    } else {
        Err(false)
    }

}