Skip to content

There is a way to make rust regex compatible with normal regex syntax ?  #32

@shachardevops

Description

@shachardevops

@BurntSushi

fn measure(pattern: &str, data: &str) {
    let start = Instant::now();

    let regex = Regex::new(pattern);
    match regex {
        Ok(re) => {
            let count = re.find_iter(data).count();

            let elapsed = Instant::now().duration_since(start);
            println!("{} - {}", elapsed.as_secs_f64() * 1e3, count);
        }
        Err(err) => {
            println!("{:?}", err);
        }
    }
}

prints

regex parse error:
    .* x-x[[0-9]+] time="[0-9\.\:\-T]+" level=error msg="x x x x ([a-z0-9]{64}): x to x device ([a-z0-9]{64})-init:devicemapper: x x x x failed""
                                           ^^
error: unrecognized escape sequence

while other languages and online regex compile it just fine
without changing the regex

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions