.TH pnmatch() "" "" "String Function (libc)"
.PC "Match string pattern"
\fBint pnmatch(\fIstring\^\fB, \fIpattern\^\fB, \fIflag\^\fB)\fR
\fBchar *\fIstring\^\fB, *\fIpattern\^\fB; int \fIflag\^\fB;\fR
.PP
.B pnmatch()
matches
.I string
with
.IR pattern , 
which is a regular expression.
The shell
.B sh
uses patterns for file name expansion and
.B case
statement expressions.
.PP
.B pnmatch()
returns one if
.I pattern
matches
.IR string ,
and zero if it does not.
Each character in
.I pattern
must exactly match a character in
.IR string ;
however, the wildcards \*(Ql*\*(Qr, \*(Ql?\*(Qr, \*(Ql[\*(Qr and
\*(Ql]\*(Qr, and \*(Ql[!\*(Qr and \*(Ql]\*(Qr can be used in
.I pattern
to expand the range of matching.
.PP
.I flag
must be either zero or one:
zero means that
.I pattern
must match
.I string
exactly, whereas one means that
.I pattern
can match any part of
.IR string .
In the latter case, the wildcards \*(Ql\*^\*(Qr
and \*(Ql$\*(Qr can also be used in
.IR pattern .
.SH Example
For an example of this function, see the entry for \fBfgets()\fR.
.SH "See Also"
.Xr "egrep," egrep
.Xr "grep," grep
.Xr "libc," libc
.Xr "sh," sh
.Xr "string.h," string.h
.Xr "wildcards" wildcards
.SH Notes
.I flag
must be zero or one for
.B pnmatch()
to yield predictable results.
.PP
.B pnmatch()
is a more powerful version of the ANSI functions
.B strstr()
and
.BR strcmp() .
.PP
For an
.BR egrep -style
version of
.BR pnmatch() ,
see the function
.BR regexp() .
It is described in the Lexicon article
.BR libmisc .
