regexec is used to match a null-terminated string against the precompiled
pattern buffer, preg. nmatch and pmatch are used to
provide information regarding the location of any matches. eflags may
be the bitwise-or of one or both of REG_NOTBOL and
REG_NOTEOL which cause changes in matching behaviour described below.
The match-beginning-of-line operator always fails to match
(but see the compilation flag REG_NEWLINE above) This flag may be
used when different portions of a string are passed to regexec and
the beginning of the string should not be interpreted as the beginning of
The match-end-of-line operator always fails to match (but
see the compilation flag REG_NEWLINE above)
Unless REG_NOSUB was set for the compilation of the pattern buffer, it is
possible to obtain substring match addressing information. pmatch must
be dimensioned to have at least nmatch elements. These are filled in by
regexec with substring match addresses. Any unused structure elements
will contain the value -1.
The regmatch_t structure which is the type of pmatch is defined in
Each rm_so element that is not -1 indicates the start offset of the next
largest substring match within the string. The relative rm_eo element
indicates the end offset of the match.
regerror is used to turn the error codes that can be returned by both
regcomp and regexec into error message strings.
regerror is passed the error code, errcode, the pattern buffer,
preg, a pointer to a character string buffer, errbuf, and the
size of the string buffer, errbuf_size. It returns the size of the
errbuf required to contain the null-terminated error message string. If
both errbuf and errbuf_size are non-zero, errbuf is
filled in with the first errbuf_size - 1 characters of the error
message and a terminating null.