Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested groups leave unexpected input in remaining to parse #5

Open
merc1031 opened this issue Dec 16, 2023 · 0 comments
Open

Nested groups leave unexpected input in remaining to parse #5

merc1031 opened this issue Dec 16, 2023 · 0 comments

Comments

@merc1031
Copy link

merc1031 commented Dec 16, 2023

Expectation with scenario 1 is that the remaining to parse string does not container either of the / as they should be consumed by the outer group.

use nom::error::ErrorKind;
use nom_regex::str::re_captures;
fn main() {
  println!("{}", "Broken / still in remaining to parse");
  let re = regex::Regex::new(r"^([/](.+)[/])").unwrap();
  let parser = re_captures::<(&str, ErrorKind)>(re);
  println!("{:?}",  parser("/pr[]-/ && abc"));

  println!("{}", "Works but needs post processing");
  let re = regex::Regex::new(r"^([/].+[/])").unwrap();
  let parser = re_captures::<(&str, ErrorKind)>(re);
  println!("{:?}",  parser("/pr[]-/ && abc"));

  println!("{}", "/ still in remaining to parse");
  let re = regex::Regex::new(r"^[/](.+)[/]").unwrap();
  let parser = re_captures::<(&str, ErrorKind)>(re);
  println!("{:?}",  parser("/pr[]-/ && abc"));

}

repl.it https://replit.com/@merc1031/IllAttentiveDrivers#src/main.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant