Skip to main content

match_pattern

Function match_pattern 

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

检查值是否匹配给定的模式

§Arguments

  • value - 要检查的字符串值
  • pattern - 包含通配符的模式字符串

§Returns

如果值匹配模式则返回 true,否则返回 false

§Examples

use aster::permission::pattern::match_pattern;

assert!(match_pattern("file_read", "file_*"));
assert!(match_pattern("file_write", "file_*"));
assert!(match_pattern("bash_exec", "bash_?xec"));
assert!(!match_pattern("other_tool", "file_*"));