Skip to content

Nested groups leave unexpected input in remaining to parse #5

Open
@merc1031

Description

@merc1031

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions