Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)
OSS Library Calls (n - r) regcmp(3)
NAME
regcmp - Compiles regular expressions
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZSTFNSRL
G-series native OSS processes: /G/system/sysnn/zstfnsrl
H-series and J-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zcrtldll
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/ycrtldll
SYNOPSIS
#include <libgen.h>
char *regcmp(const char *string1, ... /*,
(char *)0 */);
PARAMETERS
string1, ... Is a list of pointers to strings that will be concatenated and compiled. This list
must end with a null pointer.
DESCRIPTION
The regcmp( ) function concatenates the strings pointed to by the string1, ... parameters, com-
piles the result into an internal format, and returns a pointer to the compiled regular expression.
If a string contains an invalid argument, a null pointer is returned. The malloc( ) function
reserves space for the compiled form, so it is important to remember to free this space when it is
no longer needed.
The following regular expression symbols are valid:
[ ] * . ˆ Have the same meanings as defined in the re_comp(3) reference page.
$ Matches the end of the string. The \n character matches a newline.
- When used within brackets, signifies an ASCII character range. For example,
specifying [a-d] is the same as specifying [abcd]. If the hyphen is the first or last
character within the brackets, it represents itself. For example, [a-] matches two
characers, ’a’ and ’-’.
+ Matches one or more consecutive occurences of the preceding regular expres-
sion. For example, [a-z]+ is the same as [a-z][a-z]*.
{m}{m,} {m,u} Matches a given number of consecutive occurrences of the preceding regular
expression. The {m,u} syntax matches from m to u occurrences where m and u
are integers indicating the maximum and minimum number of occurrences,
respectively. The {m} syntax matches exactly m occurrences while the {m,} syn-
tax matches m or more occurences.
(...)$n Returns the value of the enclosed regular expression (subexpression). The value
is stored in the location pointed to by the n+1th parameter in the se0, ... list
where n is a single digit. If there are fewer than n parameters in this list, the
behavior of regex( ) is undefined. A maximum of ten enclosed regular expres-
sions are allowed.
(...) Groups a regular expression. A regular expression in parentheses can be fol-
lowed by an operator like *, +, or {}. These operators have the same effect on a
group regular expression as they do on a single character.
All of these regular expression symbols are special characters. To use them as themselves, you
must escape them by preceding them with a backslash.
527187-017 Hewlett-Packard Company 5−161