8 releases

0.1.8 Jul 28, 2024
0.1.7 Jul 14, 2024

#763 in Text processing

Download history 65/week @ 2024-07-22 83/week @ 2024-07-29 11/week @ 2024-09-16 1/week @ 2024-09-23 29/week @ 2024-09-30 1/week @ 2024-10-07

375 downloads per month

MIT license

17KB
248 lines

Rust Regular Expression DSL

This crate was build to help using hard coded regular expressions.

Why

While regular expressions is a powerful tool to parse and validate strings, they are hard to maintain from within a codebase. This is from a few reason reason:

  • The compiler won't identify invalid regular expression. This means that one need to test the regular expression in run time and that one need to add code to handle an invalid regular expression (which can not happen for a valid hard coded regular expression).
  • Long regular expression are hard to read for humans. This means that maintaining a regular expressions can be harder than rewriting them.
  • Capture groups index access return an optional that might be none if the group is not define, or when the group was not caught (for example, for a regular expression like ([a-z]+)|([A-Z]+) has two group but only one will be caught, so none for index 3 has different meaning from none in index 1).
  • Named capture groups has access by string - so the compiler won't complain if one gt the string wrong.

Getting Started

Add

[dependencies]
rust-regex-dsl = "0.1"

To the Cargo.toml manifest. And use either one of the available macros.

Example

See here.

Dependencies

~3–4.5MB
~84K SLoC