1<regex.h>(0P) POSIX Programmer's Manual <regex.h>(0P)
2
3
4
6 regex.h - regular expression matching types
7
9 #include <regex.h>
10
12 The <regex.h> header shall define the structures and symbolic constants
13 used by the regcomp(), regexec(), regerror(), and regfree() functions.
14
15 The structure type regex_t shall contain at least the following member:
16
17
18 size_t re_nsub Number of parenthesized subexpressions.
19
20 The type size_t shall be defined as described in <sys/types.h> .
21
22 The type regoff_t shall be defined as a signed integer type that can
23 hold the largest value that can be stored in either a type off_t or
24 type ssize_t. The structure type regmatch_t shall contain at least the
25 following members:
26
27
28 regoff_t rm_so Byte offset from start of string
29 to start of substring.
30 regoff_t rm_eo Byte offset from start of string of the
31 first character after the end of substring.
32
33 Values for the cflags parameter to the regcomp() function are as fol‐
34 lows:
35
36 REG_EXTENDED
37 Use Extended Regular Expressions.
38
39 REG_ICASE
40 Ignore case in match.
41
42 REG_NOSUB
43 Report only success or fail in regexec().
44
45 REG_NEWLINE
46 Change the handling of <newline>.
47
48
49 Values for the eflags parameter to the regexec() function are as fol‐
50 lows:
51
52 REG_NOTBOL
53 The circumflex character ( '^' ), when taken as a special char‐
54 acter, does not match the beginning of string.
55
56 REG_NOTEOL
57 The dollar sign ( '$' ), when taken as a special character, does
58 not match the end of string.
59
60
61 The following constants shall be defined as error return values:
62
63 REG_NOMATCH
64 regexec() failed to match.
65
66 REG_BADPAT
67 Invalid regular expression.
68
69 REG_ECOLLATE
70 Invalid collating element referenced.
71
72 REG_ECTYPE
73 Invalid character class type referenced.
74
75 REG_EESCAPE
76 Trailing '\' in pattern.
77
78 REG_ESUBREG
79 Number in \digit invalid or in error.
80
81 REG_EBRACK
82 "[]" imbalance.
83
84 REG_EPAREN
85 "\(\)" or "()" imbalance.
86
87 REG_EBRACE
88 "\{\}" imbalance.
89
90 REG_BADBR
91 Content of "\{\}" invalid: not a number, number too large, more
92 than two numbers, first larger than second.
93
94 REG_ERANGE
95 Invalid endpoint in range expression.
96
97 REG_ESPACE
98 Out of memory.
99
100 REG_BADRPT
101 '?', '*', or '+' not preceded by valid regular expression.
102
103 REG_ENOSYS
104 Reserved.
105
106
107 The following shall be declared as functions and may also be defined as
108 macros. Function prototypes shall be provided.
109
110
111 int regcomp(regex_t *restrict, const char *restrict, int);
112 size_t regerror(int, const regex_t *restrict, char *restrict, size_t);
113 int regexec(const regex_t *restrict, const char *restrict, size_t,
114 regmatch_t[restrict], int);
115 void regfree(regex_t *);
116
117 The implementation may define additional macros or constants using
118 names beginning with REG_.
119
120 The following sections are informative.
121
123 None.
124
126 None.
127
129 None.
130
132 <sys/types.h>, the System Interfaces volume of IEEE Std 1003.1-2001,
133 regcomp(), the Shell and Utilities volume of IEEE Std 1003.1-2001
134
136 Portions of this text are reprinted and reproduced in electronic form
137 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
138 -- Portable Operating System Interface (POSIX), The Open Group Base
139 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
140 Electrical and Electronics Engineers, Inc and The Open Group. In the
141 event of any discrepancy between this version and the original IEEE and
142 The Open Group Standard, the original IEEE and The Open Group Standard
143 is the referee document. The original Standard can be obtained online
144 at http://www.opengroup.org/unix/online.html .
145
146
147
148IEEE/The Open Group 2003 <regex.h>(0P)