#parser-combinator #regex #parser

no-std nom-regex

regular expressions for nom parsers

2 unstable releases

0.2.0 Aug 21, 2021
0.1.0 Jul 25, 2021

#114 in Parser tooling

Download history 7512/week @ 2023-12-10 7246/week @ 2023-12-17 4932/week @ 2023-12-24 5647/week @ 2023-12-31 7134/week @ 2024-01-07 7279/week @ 2024-01-14 6652/week @ 2024-01-21 7448/week @ 2024-01-28 5902/week @ 2024-02-04 4845/week @ 2024-02-11 4559/week @ 2024-02-18 4333/week @ 2024-02-25 5498/week @ 2024-03-03 5258/week @ 2024-03-10 5923/week @ 2024-03-17 8663/week @ 2024-03-24

25,749 downloads per month
Used in 2 crates (via fclones)

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

~2.9–4MB
~70K SLoC