#regex #macro #rulex

deprecated macro rulex-macro

DEPRECATED: Use pomsky-macro instead. Macro for converting pomsky expressions to regexes

4 releases (2 breaking)

0.4.4 Aug 24, 2022
0.4.3 Jun 19, 2022
0.3.0 Mar 29, 2022
0.1.1 Mar 11, 2022

#455 in #regex

MIT/Apache

260KB
5K SLoC

rulex-macro

⚠️ DEPRECATED ⚠️ Use the pomsky-macro crate instead. Rulex was renamed to pomsky.

This Rust procedural macro allows converting a rulex expression to a regex string literal at compile time:

use rulex_macro::rulex;

const REGEX: &str = rulex!("foo" | "bar"+ greedy);

This string can then used with the regex crate:

let my_regex = regex::Regex::new(REGEX).unwrap();

Diagnostics

Errors from rulex are shown at compile time and are highlighted in your IDE. You can improve the diagnostics by enabling the diagnostics feature, which requires Rust Nightly.

Regex flavor

If you want to use a regex flavor other than Rust, you can specify it after a hashtag:

const REGEX: &str = rulex!(
    #flavor = Pcre
    >> "test" %
);

License

Dual-licensed under the MIT license or the Apache 2.0 license.

Dependencies

~1.2–1.8MB
~37K SLoC