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