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

r
regcomp(3C) regcomp(3C)
NAME
regcomp( ), regerror( ), regexec( ), regfree( ) - regular expression matching routines
SYNOPSIS
#include <regex.h>
int regcomp(regex_t *preg, const char *pattern, int cflags);
int regexec(
const regex_t *preg,
const char *string,
size_t nmatch,
regmatch_t pmatch[ ],
int eflags
);
void regfree(regex_t *preg);
size_t regerror(
int errcode,
const regex_t *preg,
char *errbuf,
size_t errbuf_size
);
DESCRIPTION
These functions interpret regular expressions as described in regexp(5). They support both basic and
extended regular expressions.
The structures
regex_t and regmatch_t are defined in the header <regex.h>.
The
regex_t structure contains at least the following member (use of other members results in non-
portable code):
size_t re_nsub Number of parenthesized subexpressions.
The
regmatch_t structure contains at least the following members:
regoff_t rm_so Byte offset from start of string to start of substring.
regoff_t rm_eo Byte offset from start of string to the first character after the end of the
substring.
regcomp() compiles the regular expression specified by the pattern argument and places the results in
the structure pointed to by preg. The cflags argument is the bit-wise logical
OR of zero or more of the fol-
lowing flags (defined in <
regex.h>):
REG_EXTENDED Use extended regular expressions.
REG_NEWLINE IF REG_NEWLINE is not set in cflags, a newline character in pattern or string
is treated as an ordinary character. If REG_NEWLINE is set, newlines are
treated as ordinary characters except as follows:
1. A newline in string is not matched by a period outside of a bracket
expression or by any form of a nonmatching list.
2. A circumflex (
ˆ)inpattern , when used to specify expression anchoring,
matches the zero-length string immediately after a newline in string,
regardless of the setting of REG_NOTBOL.
3. A dollar-sign (
$)inpattern , when used to specify expression anchor-
ing, matches the zero-length string immediately before a newline in
string, regardless of the setting of REG_NOTEOL.
REG_ICASE Ignore case in match. If a character in pattern is defined in the current
LC_CTYPE locale as having one or more opposite-case counterpoints, both the
character and any counterpoints match the pattern character. This applies to all
portions of the pattern, including a string of characters specified to be matched
via a back-reference expression (\n).
Within bracket expressions : Collation ranges, character classes, and equivalence
classes are effectively expanded into equivalent lists of collation elements and
HP-UX 11i Version 2: August 2003 1 Hewlett-Packard Company Section 3847