vrl/datadog/filter/
regex.rs1use regex::Regex;
2
3#[allow(clippy::module_name_repetitions)] #[must_use]
9pub fn word_regex(to_match: &str) -> Regex {
10 Regex::new(&format!(
11 r"\b{}\b",
12 regex::escape(to_match).replace("\\*", ".*")
13 ))
14 .expect("invalid wildcard regex")
15}
16
17#[allow(clippy::module_name_repetitions)] #[must_use]
23pub fn wildcard_regex(to_match: &str) -> Regex {
24 Regex::new(&format!(
25 "^{}$",
26 regex::escape(to_match).replace("\\*", ".*")
27 ))
28 .expect("invalid wildcard regex")
29}