#regex-parser #nom

no-std nom-regex

regular expressions for nom parsers

2 unstable releases

0.2.0 Aug 21, 2021
0.1.0 Jul 25, 2021

#1230 in Parser implementations

Download history 3703/week @ 2024-07-20 3810/week @ 2024-07-27 3721/week @ 2024-08-03 5346/week @ 2024-08-10 4242/week @ 2024-08-17 3388/week @ 2024-08-24 3498/week @ 2024-08-31 2995/week @ 2024-09-07 3244/week @ 2024-09-14 3008/week @ 2024-09-21 2720/week @ 2024-09-28 2760/week @ 2024-10-05 2628/week @ 2024-10-12 2677/week @ 2024-10-19 3067/week @ 2024-10-26 2478/week @ 2024-11-02

11,374 downloads per month
Used in 13 crates (4 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
~73K SLoC