Skip to main content

promote

Function promote 

Source
pub fn promote(pat: &str) -> String
Expand description

Produce the regex source a raw pattern promotes to, without anchoring.

ยงExamples

use coding_tools::pattern::promote;

assert_eq!(promote("a.b"), "a.b"); // valid regex: used as written
assert_eq!(promote("a+b"), "a+b"); // valid regex
assert_eq!(promote("*.rs"), r"[^/]*\.rs"); // glob -> regex
assert_eq!(promote("v1.0"), "v1.0"); // '.' is a regex metachar, kept as-is