#regex #regex-parser #regular

no-std nom-regex

regular expressions for nom parsers

2 unstable releases

0.2.0 Aug 21, 2021
0.1.0 Jul 25, 2021

#13 in #regular

Download history 3680/week @ 2024-06-14 3600/week @ 2024-06-21 3796/week @ 2024-06-28 3698/week @ 2024-07-05 3859/week @ 2024-07-12 3686/week @ 2024-07-19 3870/week @ 2024-07-26 3610/week @ 2024-08-02 5255/week @ 2024-08-09 4375/week @ 2024-08-16 3415/week @ 2024-08-23 3535/week @ 2024-08-30 3015/week @ 2024-09-06 3084/week @ 2024-09-13 3277/week @ 2024-09-20 2353/week @ 2024-09-27

12,380 downloads per month
Used in 11 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