Guardian Native C Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)
regcomp(3) Guardian Native C Library Calls Reference Manual
} else {
printf(
"There are %i subexpressions in re\n", preg.re_nsub);
matches_tocheck = preg.re_nsub;
}
error = regexec(&preg, string, MAX_MATCH, &pmatch[0], 0);
if (error == REG_NOMATCH) {
printf("String did not contain match for entire re\n");
return;
} else if (error != 0) {
msize = regerror(error, &preg, message, SLENGTH);
printf("regexe: %s\n", message);
if (msize > SLENGTH)
printf("Additional text lost\n");
return;
} else
printf("String contained a match for the entire re\n");
for (count = 0; count <= matches_tocheck; count++) {
if (pmatch[count].rm_so != -1) {
printf(
"Subexpression %i matched in string\n", count);
printf(
"Match starts at %i. Byte after match is %i\n",
pmatch[count].rm_so, pmatch[count].rm_eo);
} else
printf(
"Subexpression %i had NO match\n", count);
}
regfree(&preg);
}
RETURN VALUES
Upon successful completion, the regcomp() function returns a value of 0 (zero). Otherwise, it
returns one the following nonzero values indicating the type of failure. If the regcomp() func-
tion fails, the contents of the preg parameter is undefined.
If the regexec() function finds a match, it returns a value of 0 (zero). If it does not find a match
or fails for another reason, it returns one the following nonzero values indicating the type of
failure. If the regexec() function does not find a match or fails for another reason, the contents
of the pmatch parameter is undefined.
Unless otherwise noted, the following values are returned by the regcomp() function only.
REG_BADBR The contents within the pair \{ (backslash left brace) and \} (backslash right
brace) are unusable: Not a number, number too large, more than two numbers, or
first number larger than second.
REG_BADPAT
There is an unusable basic regular expression or extended regular expression.
This value is returned by the regexec() function only.
5−102 Hewlett-Packard Company 527192-018