Skip to main content

compile_anchored

Function compile_anchored 

Source
pub fn compile_anchored(pat: &str) -> Result<Regex, Error>
Expand description

Compile a pattern for whole-name matching: anchored to the full string, so *.java means “the name ends in .java”, not merely “contains”.

§Examples

use coding_tools::pattern::compile_anchored;

let re = compile_anchored("*.rs").unwrap();
assert!(re.is_match("main.rs"));
assert!(!re.is_match("main.rs.bak")); // anchored: must end in .rs