Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)
regcomp(3) OSS Library Calls Reference Manual
pattern Contains the basic or extended regular expression to be compiled by regcomp( ).
The default regular expression type for the pattern parameter is a basic regular
expression. An application can specify extended regular expressions with the
REG_EXTENDED flag. If the REG_NOSUB flag is not set in the cflags
parameter, the regcomp( ) function sets the number of parenthetic subexpres-
sions (delimited by a \( (backslash left parenthesis) and \) (backslash right
parenthesis) pair in basic regular expressions, or ( ) (parentheses) in extended
regular expressions) to the number found in the pattern parameter.
preg The structure that contains the compiled basic or extended regular expression.
errcode Identifies the error code.
errbuf Points to the buffer where regerror( ) stores the message text.
errbuf_size Specifies the size of the errbuf buffer.
string Contains the data to be matched.
nmatch Contains the number of subexpressions to match.
pmatch Contains the array of offsets into the string parameter that match the correspond-
ing subexpression in the preg parameter.
eflags Contains the bitwise inclusive OR of zero or more of the flags controlling the
customizable behavior of the regexec function.
The eflags parameter modifies the interpretation of the contents of the string
parameter. The value for this parameter is formed by bitwise inclusive ORing
zero or more of the following flags, which are defined in the
/usr/include/regex.h file.
REG_NOTBOL
The first character of the string pointed to by the string parameter is not the beginning
of the line. Therefore, the circumflex character ˆ (circumflex), when taken as a special
character, does not match the beginning of the string parameter.
REG_NOTEOL
The last character of the string pointed to by the string parameter is not the end of the
line. Therefore, the $ (dollar sign), when taken as a special character, does not match
the end of the string parameter.
DESCRIPTION
The regcomp( ), regerror( ), regexec( ), and regfree() functions perform regular expression
matching. The regcomp( ) function compiles a regular expression and the regexec( ) function
compares the compiled regular expression to a string. The regerror( ) function returns text asso-
ciated with an error condition encountered by regcomp( ) or regexec(). The regfree() function
frees the internal storage allocated for the compiled regular expression.
The regcomp( ) function compiles the basic or extended regular expression specified by the pat-
tern parameter and places the output in the preg structure.
The regexec() function compares the NULL terminated string in the string parameter against the
compiled basic or extended regular expression in the preg parameter. If a match is found, the
regexec( ) function returns a value of 0 (zero). The regexec( ) function returns a nonzero value if
there is no match or if there is an error.
If the value of the nmatch parameter is 0 (zero), or if the REG_NOSUB flag was set on the call
to the regcomp( ) function, the regexec( ) function ignores the pmatch parameter. Otherwise, the
5−164 Hewlett-Packard Company 527187-017