.TH fnmatch() "" "" "String Function (libc)"
.PC "Match a string with a normal expression"
.B "#include <fnmatch.h>"
\fBint fnmatch(\fIpattern\^\fB, \fIstring\^\fB, \fIflags\^\fB)
\fBconst char *\fIpattern\^\fB, *\fIstring\^\fB; \fIint \fIflags\^\fB;\fR
.PP
The function
.B fnmatch()
checks whether the string to which
.I string
points matches the normal expression to which
.I pattern
points.
A
.I "normal expression"
is one that uses wildcard characters to broaden the range of strings
that it matches.
For more information, see the Lexicon entry for
.BR wildcards .
.PP
.I flags
is a bit map whose bits are defined in the header file
.BR <fnmatch.h> .
.B fnmatch()
recognizes any or all of following flags:
.IP \fBFNM_NOESCAPE\fR
Disable recognizing the backslash as an escape character.
.IP
If this flag is not set, then prefixing a character in
.I pattern
with a backslash `\e' matches that same character in
.IR string .
For example, the pair `\e*' in
.I pattern
matches a literal `*' in
.IR string ;
and the pair `\e\e' in
.I pattern
matches `\e' in
.IR string .
.IP \fBFNM_PATHNAME\fR
A slash `/' in
.I string
matches only a slash in
.IR pattern .
If this flag is set, then a `/' in
.IR string
will not match a wildcard character in
.IR pattern .
.IP \fBFNM_PERIOD\fR
A leading period `.' in
.I string
must be matched exactly by a period in
.IR pattern .
If
.B FNM_PATHNAME
is set, then a ``leading'' period is one that occurs either at the beginning of
.I string
or immediately following a slash; if it is not set, then a
``leading'' period is one that appears at the beginning of
.IR string .
If
.B FNM_PERIOD
is not set, then
.B fnmatch()
places no special restrictions on matching a period.
.PP
If
.I string
matches
.IR pattern ,
.B fnmatch()
returns zero.
If it does not match,
.B fnmatch()
returns
.BR FN_NOMATCH .
If an error occurs,
.B fnmatch()
returns a value other than zero or
.BR FN_NOMATCH .
.SH "See Also"
.Xr "libc," libc
.Xr "pnmatch()," pnmatch
.Xr "string.h," string.h
.Xr "wildcards" wildcards
