ctreg
ctreg (pronounced cuh-tredge, in the style of Cthulhu) is a macro providing
static typing to your regular expressions, allowing syntax errors to be detected
at compile time and capture groups to be matched infallibly.
use regex;
// Create a regular expression with the macro. This regular expression is
// analyzed at compile time and its parsed, normalized representation is
// emitted as the `HelloWorld` type.
regex!
// Create an instance of the regular expression.
let regex = new;
// Use `is_match` to test if there was a match
assert!;
assert!;
assert!;
// Use `find` to find the location of a match
let cap = regex.find.unwrap;
assert_eq!;
assert_eq!;
assert_eq!;
assert!;
// Use `captures` to find all of the named capture groups of a match (`greeting`
// and `target`, in this case). Capture groups are emitted at compile time and
// evaluated infallibly.
let groups = regex.captures.unwrap;
assert_eq!;
assert_eq!;
let groups = regex.captures.unwrap;
assert_eq!;
assert!;
assert!;