Struct remake::Remake [] [src]

pub struct Remake { /* fields omitted */ }

A remake expression, which can be compiled into a regex.

Methods

impl Remake
[src]

[src]

Evaluate some remake source to produce a regular expression.

Example: A mostly-wrong URI validator

use remake::Remake;
let web_uri_re = Remake::compile(
    r#"
    let scheme = /https?:/ . '//';
    let auth = /[\w\.\-_]+/;
    let path = ('/' . /[\w\-_]+/)*;
    let query_body = (/[\w\.\-_?]/ | '/')*;
    let frag_body = cap query_body as frag;

      /^/
    . scheme . auth . path
    . ('?' . query_body)?
    . ('#' . frag_body)?
    . /$/
    "#,
).unwrap();

assert!(web_uri_re.is_match("https://www.rust-lang.org"));
assert!(web_uri_re.is_match("https://github.com/ethanpailes/remake"));

assert_eq!(
    web_uri_re
        .captures("https://tools.ietf.org/html/rfc3986#section-1.1.3")
        .unwrap()
        .name("frag")
        .unwrap()
        .as_str(),
    "section-1.1.3"
);

Errors:

Calling compile on some remake source might result in an Error.

[src]

Construct a remake expression which can be evaluated at a later time.

To go directly from a remake expression to a Regex, see Remake::compile.

Example:

let remake_expr = Remake::new(r" 'a literal' ".to_string())?;

Errors:

Calling new on some remake source might result in a Error::ParseError.

[src]

Evaluate a remake expression.

Example:

let remake_expr = Remake::new(r" 'a [li[teral' ".to_string())?;
let re = remake_expr.eval()?;

assert!(re.is_match("a [li[teral"));

Errors:

Calling eval on a remake expression might result in a Error::RuntimeError.

Trait Implementations

impl Clone for Remake
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Send for Remake

impl Sync for Remake