Query: fnmatch
OS: php
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
FNMATCH(3) 1 FNMATCH(3) fnmatch - Match filename against a patternSYNOPSISbool fnmatch (string $pattern, string $string, [int $flags])DESCRIPTIONfnmatch(3) checks if the passed $string would match the given shell wildcard $pattern.PARAMETERSo $pattern - The shell wildcard pattern. o $string - The tested string. This function is especially useful for filenames, but may also be used on regular strings. The average user may be used to shell patterns or at least in their simplest form to '?' and '*' wildcards so using fnmatch(3) instead of preg_match(3) for frontend search expression input may be way more convenient for non-programming users. o $flags - The value of $flags can be any combination of the following flags, joined with the binary OR (|) operator. A list of possible flags for fnmatch(3) +-------------+---------------------------------------------------+ | $Flag | | | | | | | Description | | | | +-------------+---------------------------------------------------+ | | | |FNM_NOESCAPE | | | | | | | Disable backslash escaping. | | | | | | | |FNM_PATHNAME | | | | | | | Slash in string only matches slash in the given | | | pattern. | | | | | | | | FNM_PERIOD | | | | | | | Leading period in string must be exactly matched | | | by period in the given pattern. | | | | | | | |FNM_CASEFOLD | | | | | | | Caseless match. Part of the GNU extension. | | | | +-------------+---------------------------------------------------+RETURN VALUESReturns TRUE if there is a match, FALSE otherwise.CHANGELOG+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.0 | | | | | | | This function is now available on Windows plat- | | | forms. | | | | +--------+---------------------------------------------------+EXAMPLESExample #1 Checking a color name against a shell wildcard pattern <?php if (fnmatch("*gr[ae]y", $color)) { echo "some form of gray ..."; } ?>NOTESWarning For now, this function is not available on non-POSIX compliant systems except Windows.SEE ALSOglob(3), preg_match(3), sscanf(3), printf(3), sprintf(3). PHP Documentation Group FNMATCH(3)
Related Man Pages |
---|
fnmatch(3) - linux |
fnmatch(3) - suse |
fnmatch(3) - opendarwin |
fnmatch(3) - bsd |
fnmatch(3) - xfree86 |
Similar Topics in the Unix Linux Community |
---|
Searching for a pattern |
help- wildcard not working in shell |
Replace a string in a file |
To search the pattern on the basis of date and exit code |
Wildcard Pattern Matching In C |