COHERENT manpages

This page displays the COHERENT manpage for regexec() [Compare a string with a regular expression].

List of available manpages
Index


regexec() -- Regular-Expression Function (libc)

Compare a string with a regular expression
#include <regexp.h>
int regexec(expression, string)
regexp *expression;
char *string;

Function  regexec() compares  string with  expression,  which is  a regular
expression compiled  by function  regcomp(). If string  matches expression,
regexec() returns  one; otherwise, it  returns zero and  readjusts the sub-
string pointers within expression.

For details  on the structure  regexp and its sub-string  pointers, see the
Lexicon  entry for  regexp.h. In brief,  if regexec()  successfully matches
string with  expression, it initializes  arrays startp[] and  endp[] within
expression. Each startp/endp pair point to one substring within string: the
startp element points to the first  character of the substring and the endp
element points to the first character that follows the substring.  The pair
startp[0]/endp[0] points to the  substring of string that matched the whole
of expression.  The other pairs point to the  substrings within string that
matched  parenthesized expressions  within  expression, with  parenthesized
expressions numbered in left-to-right order of their opening parentheses.

See Also

libc,
regexp.h