Open System Services Library Calls Reference Manual (G06.28+, H06.05+)
OSS Library Calls (n - r) regcomp(3)
|
• ||
If a subexpression matched a zero-length string, the offsets in the
pmatch parameter refer |
to the byte immediately following the matching string. |
If the REG_NOSUB flag was set in the cflags parameter in the call to the regcomp() function, |
and the nmatch parameter is not equal to 0 (zero) in the call to the regexec function, the content |
of the pmatch array is unspecified. |
If the REG_NEWLINE flag was not set in the cflags parameter when the regcomp() function |
was called, then a newline character in the pattern or string parameter is treated as an ordinary |
character. If the REG_NEWLINE flag was set when the regcomp() function was called, the |
newline character is treated as an ordinary character, except as follows: |
|
• ||
A newline character in the string parameter is not matched by a . (dot) outside of a |
bracket expression or by any form of a nonmatching list. |
|
• ||
A ˆ (circumflex) in the pattern parameter, when used to specify expression anchoring, |
matches the zero-length string immediately after a newline character in the string param- |
eter, regardless of the setting of the REG_NOTBOL flag. |
|
• ||
A $ (dollar sign) in the pattern parameter, when used to specify expression anchoring, |
matches the zero-length string immediately before a newline character in the string |
parameter, regardless of the setting of the REG_NOTEOL flag. |
The regerror() function returns the text associated with the specified error code. If the |
regcomp() or regexec() function fails, it returns a nonzero error code. If this return value is |
assigned to the errcode parameter, the regerror() function returns the text of the associated mes- |
sage. |
The regfree() function frees any memory allocated by the regcomp() function associated with |
the preg parameter. An expression defined by the preg parameter is no longer treated as a com- |
piled basic or extended regular expression after it is given to the regfree() function. |
EXAMPLES |
|
1. ||
The following example demonstrates how the REG_NOTBOL flag can be used with the |
regexec() function to find all substrings in a line that match a pattern supplied by a user. |
The main() function in the example accepts two input strings from the user. The |
match() function in the example uses regcomp() and regexec() to search for matches. |
#include <sys/types.h>
|
#include <regex.h>
|
#include <locale.h> |
#include <stdio.h> |
#include <string.h> |
#define SLENGTH 80 |
main() |
{ |
527187-007 Hewlett-Packard Company 5−93