Guardian Native C Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

Guardian Native C Library Calls (n - r) re_exec(3)
consecutive ASCII characters. For example, [0-9] is the same as [0123456789]. If, how-
ever, the minus sign is the first character (following any initial "ˆ") or the last character
within the bracketed string, it loses this special meaning.
When a right square bracket is the first character (following any initial "ˆ") within a
bracketed string, it has no special meaning and simply matches itself.
When the ",", "*", "[", or "\" characters appear within a bracketed string, they have no
special meaning and simply match themselves.
To construct more complex regular expression strings from the one-character regular expression
strings, the following rules are used:
1. A one-character regular expression string matches is a regular expression string that
matches whatever the one-character regular expression string matches.
2. A one-character regular expression string followed by an asterisk (*) is a regular expres-
sion string that matches 0 (zero) or more occurrences of the one-character regular expres-
sion string. The longest leftmost string that matches is chosen.
3. A one-character regular expression string followed by \{m\}, \{m,\},or\{m,n\} (where m
and n are non-negative integers less than 256) is a regular expression string that matches
a range of occurrences of the one-character regular expression string. \{m\} matches
exactly m occurrences; \{m,\} matches at least m occurrences; and \{m,n\} matches
between m and n occurrences, inclusive.
4. The concatenation of two or more regular expression strings matches a concatenation of
the strings matched by the individual regular expression strings.
5. A regular expression string enclosed with \( and \) is a regular expression string that
matches whatever the enclosed regular expression string matches.
6. The expression \n matches the same character string matched by an expression enclosed
within \( and \) earlier in the same regular expression string. In particular, the earlier
string is that beginning with the nth occurrence of \( counting from the left.
Finally, the circumex (ˆ) and dollar sign ($) characters can be used to limit a regular expression
string to matching the initial segment, the final segment of the line, or both.
1. If a regular expression string has a circumflex (ˆ) as its first character, the regular expres-
sion string must match the initial segment of a line.
2. If a regular expression string has a dollar sign ($) as its last character, the regular expres-
sion string must match the final segment of a line. The construct ˆregexp$ means that the
regular expression string regexp must match the entire line.
A null regular expression string (that is, //) is equivalent to the last regular expression string
encountered.
NOTES
This function can be called by a native process only.
The behavior of this function in locales other than POSIX is undefined.
RETURN VALUES
When the re_exec() function completes successfully and the string pointed to by the string
parameter matches the last compiled regular expression, it returns 1. Otherwise, it returns 0
(zero) if the match failed, and -1 if the compiled regular expression was invalid (indicating an
internal error).
527192-018 Hewlett-Packard Company 593