#regex #compile-time #validation #lazy-evaluation #regex-validation #functions-and-static

regex_static

Compile-time validated regex, with convenience functions for lazy and static regexes

2 releases

0.1.1 Mar 20, 2021
0.1.0 Mar 4, 2021

#374 in Science

Download history 1962/week @ 2025-09-19 1208/week @ 2025-09-26 2776/week @ 2025-10-03 2510/week @ 2025-10-10 2251/week @ 2025-10-17 2255/week @ 2025-10-24 3211/week @ 2025-10-31 5760/week @ 2025-11-07 3863/week @ 2025-11-14 2628/week @ 2025-11-21 2961/week @ 2025-11-28 3668/week @ 2025-12-05 4062/week @ 2025-12-12 1766/week @ 2025-12-19 1506/week @ 2025-12-26 3773/week @ 2026-01-02

11,497 downloads per month
Used in 16 crates (6 directly)

Apache-2.0 OR MIT OR CC0-1.0

4KB

regex_static

Compile-time validation of regex::Regex.

Examples

Lazy regex

Uses once_cell to lazily create the regex.

static RE: Lazy<Regex> = regex_static::lazy_regex!("^yesss$");

Static regex

Also uses once_cell, but works inline (will therefore reuse the same instance of the regex each function call).

let some_regex = regex_static::static_regex!("^yesss$");

Ordinary regex

Will create an owned Regex, just like calling Regex::new(...) but with compile-time validation.

let ordinary_regex = regex_static::regex!("^yesss$");

Dependencies

~3.5–4.5MB
~92K SLoC