fancy-regex / fancy-regex

Rust library for regular expressions using "fancy" features like look-around and backreferences
MIT License
402 stars 35 forks source link

Version 0.13.0 throws an Error::BacktrackLimitExceeded #138

Open jcold opened 1 month ago

jcold commented 1 month ago

The following code snippet works fine in v0.12.0, but in v0.13.0 it throws an Error::BacktrackLimitExceeded. The regex crates have been checked and they are fine. Any assistance would be appreciated.

error message: Error executing regex: Max limit for backtracking count exceeded

#[test]
fn fancy() -> anyhow::Result<()> {
    let re = fancy_regex::Regex::new(r"\b\$?t\('(.+?)'\)")?;
    for m in re.captures_iter("content...") {
        if let Some(v) = m?.get(1) {
            println!("{}", v.as_str().to_string());
        }
    }
    Ok(())
}
keith-hall commented 1 month ago

hmm, I tried to reproduce this with the toy example and wasn't able to:

cargo run --example toy -- run '\b\$?t\('\''(.+?)'\''\)' 'content...'
Finished dev [unoptimized + debuginfo] target(s) in 0.03s
Running `target/debug/examples/toy run '\b\$?t\('\''(.+?)'\''\)' content...`
no match