Wildcard Utility¶
Utility Class for handling wildcard opertations like "b?a_*"
- class Jar\Utilities\Utilities\WildcardUtility¶
- Jar\Utilities\Utilities\WildcardUtility::matchAgainstPatternList($patterns, $string, $flags = 0)¶
Matches a string against a whole list of patterns, returns "true" on first match
- Parameters
$patterns (
array
) -- List of patterns like ['b?a_*', 'plupp_*']$string (
string
) -- The string to match.$flags (
int
) -- Flags ("FNM_PATHNAME" or 1, "FNM_NOESCAPE" or 2, "FNM_PERIOD" or 4, "FNM_CASEFOLD" or 16) based on https://www.php.net/manual/en/function.fnmatch.php#refsect1-function.fnmatch-parameters
- Returns
Returns "true" on first match, otherwise false.
- Jar\Utilities\Utilities\WildcardUtility::match($pattern, $string, $flags = 0)¶
Simple wildcard which matches a string against a pattern. Wildcards like * or ? are useable.
- Parameters
$pattern (
string
) -- The Pattern like "hello*world"$string (
string
) -- The string to match.$flags (
int
) -- Flags ("FNM_PATHNAME" or 1, "FNM_NOESCAPE" or 2, "FNM_PERIOD" or 4, "FNM_CASEFOLD" or 16) based on https://www.php.net/manual/en/function.fnmatch.php#refsect1-function.fnmatch-parameters
- Returns
Returns "true" on match, otherwise false.
Example:
$pattern = 'hello*world'; WildcardUtility::match($pattern, 'hello beatiful world'); // true WildcardUtility::match($pattern, 'hello happy planet'); // false