#parser #parser-combinators #regex

no-std nom-regex

regular expressions for nom parsers

2 unstable releases

0.2.0 Aug 21, 2021
0.1.0 Jul 25, 2021

#143 in Parser tooling

Download history 2583/week @ 2023-10-30 4416/week @ 2023-11-06 7688/week @ 2023-11-13 6826/week @ 2023-11-20 7456/week @ 2023-11-27 8138/week @ 2023-12-04 7957/week @ 2023-12-11 7695/week @ 2023-12-18 4973/week @ 2023-12-25 5880/week @ 2024-01-01 8162/week @ 2024-01-08 7448/week @ 2024-01-15 6820/week @ 2024-01-22 7915/week @ 2024-01-29 6246/week @ 2024-02-05 4516/week @ 2024-02-12

25,843 downloads per month
Used in 3 crates (2 directly)

MIT license

26KB
470 lines

nom-regex

This crate provides combinators for nom parser combinators using the regex crate.

Example

use nom::{Err, error::ErrorKind};
use nom_regex::str::re_match;
fn main() {
  let re = regex::Regex::new(r"^\d{4}").unwrap();
  let parser = re_match::<(&str, ErrorKind)>(re);
  assert_eq!(parser("2019"), Ok(("", "2019")));
  assert_eq!(parser("abc"), Err(Err::Error(("abc", ErrorKind::RegexpMatch))));
  assert_eq!(parser("2019-10"), Ok(("", "2019-10")));
}

lib.rs:

Parser combinators that use regular expressions.

This crate provides combinators for nom parser combinators using the regex crate.

Example

use nom::{Err, error::ErrorKind};
use nom_regex::str::re_match;
fn main() {
  let re = regex::Regex::new(r"^\d{4}").unwrap();
  let parser = re_match::<(&str, ErrorKind)>(re);
  assert_eq!(parser("2019"), Ok(("", "2019")));
  assert_eq!(parser("abc"), Err(Err::Error(("abc", ErrorKind::RegexpMatch))));
  assert_eq!(parser("2019-10"), Ok(("", "2019-10")));
}

Dependencies

~3–4MB
~71K SLoC