10 breaking releases

✓ Uses Rust 2018 edition

0.11.0 Aug 13, 2019
0.10.0 Jul 1, 2019
0.9.0 Jun 28, 2019
0.3.0 Jan 23, 2019

#109 in Text processing

Download history 3/week @ 2019-04-29 4/week @ 2019-05-06 5/week @ 2019-05-13 14/week @ 2019-05-20 8/week @ 2019-05-27 31/week @ 2019-06-03 25/week @ 2019-06-10 44/week @ 2019-06-17 80/week @ 2019-06-24 69/week @ 2019-07-01 76/week @ 2019-07-08 3/week @ 2019-07-15 23/week @ 2019-07-22 12/week @ 2019-07-29 48/week @ 2019-08-05

147 downloads per month
Used in 1 crate

MIT license

21KB
399 lines

rec

Regular Expression Constructor - the recreational version of regular expressions

rec is a Rust library that simplifies the process of reading and writing regular expressions. This library is intended for all users working with regular expressions, no matter their familiarity with regular expression syntax. Below is a summary of the functionality provided by rec:

  • WYSIWYG: [&str] and [char] are interpreted exactly as written (i.e. no metacharacters);
  • Uses operators from rust language syntax to provide easy to understand expressions.
  • Declares regular expressions as const [&str] values that are valid with the [regex] crate.

Getting Started

Add the following to your Cargo.toml:

[dependencies]
rec = "0.11.0"

Examples

use rec::rec;
use regex::Regex;

#[rec]
const HELLO_WORLD: &str = "hello" + [' '; 1..] + "world";

let re = Regex::new(HELLO_WORLD).unwrap();
assert!(re.is_match("hello    world"));

Alternation is implemented by |.

use rec::rec;
use regex::Regex;

#[rec]
const VERSION: &str = "debug" | "release";

let re = Regex::new(VERSION).unwrap();
assert!(re.is_match("release"));

FAQ

I know regular expression syntax; why should I use rec?

In order for code to be easily maintainable, it should be as simple as possible. Even if the original developer understands their regular expression, it is beneficial for the project as a whole if all contributors are able to easily understand the function of a regular expression.

License: MIT

Dependencies

~2MB
~61K SLoC