Crates.io | rec |
lib.rs | rec |
version | 0.11.0 |
source | src |
created_at | 2019-01-04 15:51:00.800275 |
updated_at | 2019-08-13 19:06:28.539682 |
description | Regular Expression Constructor |
homepage | |
repository | https://github.com/jsim2010/rec |
max_upload_size | |
id | 105458 |
size | 33,023 |
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
:
&str
] and [char
] are interpreted exactly as written (i.e. no metacharacters);&str
] values that are valid with the [regex
]
crate.Add the following to your Cargo.toml
:
[dependencies]
rec = "0.11.0"
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"));
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