2 unstable releases

0.2.0 Aug 21, 2021
0.1.0 Jul 25, 2021

#177 in Parser tooling

Download history 2313/week @ 2024-11-16 2213/week @ 2024-11-23 2525/week @ 2024-11-30 2363/week @ 2024-12-07 2156/week @ 2024-12-14 1657/week @ 2024-12-21 1692/week @ 2024-12-28 2477/week @ 2025-01-04 2374/week @ 2025-01-11 2306/week @ 2025-01-18 2438/week @ 2025-01-25 2432/week @ 2025-02-01 2406/week @ 2025-02-08 2342/week @ 2025-02-15 2480/week @ 2025-02-22 2482/week @ 2025-03-01

10,044 downloads per month
Used in 14 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