Skip to main content

matches_pattern

Function matches_pattern 

Source
pub fn matches_pattern(value: &str, pattern: &str) -> bool
Expand description

模式匹配 — 判断 value 是否匹配 pattern

支持三种语法:

  • 精确匹配:"bash" 匹配 "bash"
  • 管道分隔多选:"bash|write_file" 匹配 "bash""write_file"
  • 通配符 *"read_*" 匹配 "read_file", "read_dir"

§Examples

use katu_core::hook::matches_pattern;

assert!(matches_pattern("bash", "bash"));
assert!(matches_pattern("bash", "bash|write_file"));
assert!(matches_pattern("read_file", "read_*"));
assert!(!matches_pattern("write_file", "read_*"));