Skip to main content

macron_regex/
lib.rs

1#![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))]
2
3#[cfg(feature = "regex")]
4pub use regex::{self, Match, Regex};
5
6/// Creates a new instance of [Regex](https://docs.rs/regex/latest/regex/struct.Regex.html)
7#[cfg(feature = "regex")]
8#[macro_export]
9macro_rules! re {
10    ($($tokens:tt)*) => {{
11        $crate::regex::Regex::new(&::std::format!($($tokens)*)).unwrap()
12    }};
13
14    ($expr:expr) => {{
15        $crate::regex::Regex::new(&::std::format!($expr)).unwrap()
16    }};
17}
18
19/// Creates a new instance of [Regex](https://docs.rs/regex/latest/regex/struct.Regex.html)
20#[cfg(not(feature = "regex"))]
21#[macro_export]
22macro_rules! re {
23    ($($tokens:tt)*) => {{
24        ::regex::Regex::new(&::std::format!($($tokens)*)).unwrap()
25    }};
26
27    ($expr:expr) => {{
28        ::regex::Regex::new(&::std::format!($expr)).unwrap()
29    }};
30}