#expression-parser #regex-parser #parser-combinator #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

#275 in Parser tooling

Download history 1394/week @ 2025-12-05 1351/week @ 2025-12-12 1365/week @ 2025-12-19 1177/week @ 2025-12-26 1305/week @ 2026-01-02 1230/week @ 2026-01-09 1705/week @ 2026-01-16 1739/week @ 2026-01-23 1589/week @ 2026-01-30 1579/week @ 2026-02-06 1523/week @ 2026-02-13 1656/week @ 2026-02-20 1930/week @ 2026-02-27 1945/week @ 2026-03-06 2210/week @ 2026-03-13 1879/week @ 2026-03-20

8,250 downloads per month
Used in 6 crates (3 directly)

MIT license

26KB
470 lines

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")));
}

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")));
}

Dependencies

~2.6–4MB
~69K SLoC