Skip to main content

fnmatch

Function fnmatch 

Source
pub fn fnmatch(pattern: &[u8], filename: &[u8]) -> Result<bool, EngineError>
Expand description

PHP fnmatch($pattern, $filename): whether filename matches the shell glob pattern (*, ?, [...] with !/^, ranges and [:class:], \ escapes; * crosses / and a leading . is not special).

A null byte in either argument is the ValueError PHP throws; an argument of 4096 bytes or more does not match (PHP warns).

use php_std::glob::fnmatch;

assert_eq!(fnmatch(b"v1.*", b"v1.2.0"), Ok(true));
assert_eq!(fnmatch(b"v?.0.0", b"v10.0.0"), Ok(false));
assert_eq!(fnmatch(b"[!a]*", b"beta"), Ok(true));