#regex #pomsky

macro pomsky-macro

Macro for converting pomsky expressions to regexes

7 releases (breaking)

0.11.0 Nov 9, 2023
0.10.0 Mar 23, 2023
0.9.0 Jan 14, 2023
0.8.0 Dec 12, 2022
0.5.0 Jul 4, 2022

#1238 in Text processing

Download history 11/week @ 2024-07-19 9/week @ 2024-07-26 22/week @ 2024-08-02 35/week @ 2024-08-09 17/week @ 2024-08-16 19/week @ 2024-08-23 25/week @ 2024-08-30 22/week @ 2024-09-06 11/week @ 2024-09-13 67/week @ 2024-09-20 67/week @ 2024-09-27 50/week @ 2024-10-04 50/week @ 2024-10-11 52/week @ 2024-10-18 12/week @ 2024-10-25 11/week @ 2024-11-01

143 downloads per month
Used in 6 crates

MIT/Apache

185KB
4K SLoC

pomsky-macro

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

use pomsky_macro::pomsky;

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

This string can then used with the regex crate:

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

Diagnostics

Errors from pomsky 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 = pomsky!(
    #flavor = Pcre
    >> "test" %
);

License

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


lib.rs:

This crate provides the pomsky! macro to compile pomsky expressions at compile time.

Dependencies

~140KB