HP-UX Reference (11i v2 03/08) - 3 Library Functions N-Z (vol 7)

r
regcomp(3C) regcomp(3C)
regerror() provides a mapping from error codes returned by
regcomp() and regexec() to print-
able strings.
regerror() generates a string corresponding to the value of the errcode parameter,
which was the last non-zero value returned by
regcomp() or regexec() with the given value of
preg. The errcode parameter can take on any of the error values defined in <
regex.h>. If errbuf_size is
not zero,
regerror() copies an appropriate error message into the buffer specified by errbuf . If the
error message (including the terminating null) cannot fit in the buffer, it is truncated to errbuf_size 1
bytes and null terminated.
If errbuf_size is zero, the errbuf parameter is ignored, but the return value is as defined below.
regerror() returns the size of the buffer (including terminating null) that is required to hold the
entire error message.
EXTERNAL INFLUENCES
Locale
The
LC_COLLATE category determines the collating sequence used in compiling and executing regular
expressions.
The
LC_CTYPE category determines the interpretation of text as single and/or multi-byte characters, the
characters matched by character-class expressions in regular expressions, and the opposite-case counter-
part for each character.
International Code Set Support
Single- and multi-byte character code sets are supported. However, if the
LC_COLLATE and LC_CTYPE
variables specify locale categories that are not based upon the same underlying codeset, the results of
regcomp() is undefined.
RETURN VALUE
regcomp() returns zero for success and non-zero for an invalid expression or other failure.
regexec() returns zero if it finds a match and non-zero for no match or other failure.
ERRORS
If
regcomp() or regexec() detects one of the error conditions listed below, it returns the
corresponding non-zero error code. The error codes are defined in the header <
regex.h>.
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 An invalid regular expression.
REG_BADRPT The ? (question mark), * (asterisk), or + (plus sign) symbols are not preceded
by a valid regular expression.
REG_EBRACE The use of a pair of \{ (backslash left brace) and \} (backslash right brace)
or {} (braces) is unbalanced.
REG_EBRACK The use of [] (brackets) is unbalanced.
REG_EBOL Using the ˆ (caret) anchor and not beginning of line.
REG_ECHAR There is an invalid multibyte character.
REG_ECOLLATE There is an unusable collating element referenced.
REG_ECTYPE There is an unusable character class type referenced.
REG_EEOL Using the $ (dollar) anchor and not end of line.
REG_EESCAPE There is a trailing \ in the pattern.
REG_EPAREN The use of a pair of \( (backslash left parenthesis) and \) (backslash right
parenthesis) or () is unbalanced.
REG_ERANGE There is an unusable endpoint in the range expression.
REG_ESPACE There is insufficient memory space.
REG_ESUBREG The number in \digit is invalid or in error.
REG_NOMATCH The regexec() function failed to match.
HP-UX 11i Version 2: August 2003 3 Hewlett-Packard Company Section 3849