| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 
 | '\" et
.TH regex.h "0P" 2013 "IEEE/The Open Group" "POSIX Programmer's Manual"
.SH PROLOG
This manual page is part of the POSIX Programmer's Manual.
The Linux implementation of this interface may differ (consult
the corresponding Linux manual page for details of Linux behavior),
or the interface may not be implemented on Linux.
.SH NAME
regex.h
\(em regular expression matching types
.SH SYNOPSIS
.LP
.nf
#include <regex.h>
.fi
.SH DESCRIPTION
The
.IR <regex.h> 
header shall define the structures and symbolic constants used by the
\fIregcomp\fR(),
\fIregexec\fR(),
\fIregerror\fR(),
and
\fIregfree\fR()
functions.
.P
The
.IR <regex.h> 
header shall define the
.BR regex_t
structure type, which shall include at least the following member:
.sp
.RS 4
.nf
\fB
size_t    re_nsub    \fRNumber of parenthesized subexpressions.\fR
.fi \fR
.P
.RE
.P
The
.IR <regex.h> 
header shall define the
.BR size_t
type as described in
.IR <sys/types.h> .
.P
The
.IR <regex.h> 
header shall define the
.BR regoff_t
type as a signed integer type that can hold
the largest value that can be stored in either a
.BR ptrdiff_t
type or a
.BR ssize_t
type.
.P
The
.IR <regex.h> 
header shall define the
.BR regmatch_t
structure type, which shall include at least the following members:
.sp
.RS 4
.nf
\fB
regoff_t    rm_so    \fRByte offset from start of string\fR
                     \fRto start of substring.\fR
regoff_t    rm_eo    \fRByte offset from start of string of the\fR
                     \fRfirst character after the end of substring.\fR
.fi \fR
.P
.RE
.P
The
.IR <regex.h> 
header shall define the following symbolic constants for the
.IR cflags
parameter to the
\fIregcomp\fR()
function:
.IP REG_EXTENDED 14
Use Extended Regular Expressions.
.IP REG_ICASE 14
Ignore case in match.
.IP REG_NOSUB 14
Report only success or fail in
\fIregexec\fR().
.IP REG_NEWLINE 14
Change the handling of
<newline>.
.P
The
.IR <regex.h> 
header shall define the following symbolic constants for the
.IR eflags
parameter to the
\fIregexec\fR()
function:
.IP REG_NOTBOL 14
The
<circumflex>
character (\c
.BR '^' ),
when taken as a special character, does not match the beginning of
.IR string .
.IP REG_NOTEOL 14
The
<dollar-sign>
(\c
.BR '$' ),
when taken as a special character, does not match the end of
.IR string .
.P
The
.IR <regex.h> 
header shall define the following symbolic constants as error
return values:
.IP REG_NOMATCH 14
\fIregexec\fR()
failed to match.
.IP REG_BADPAT 14
Invalid regular expression.
.IP REG_ECOLLATE 14
Invalid collating element referenced.
.IP REG_ECTYPE 14
Invalid character class type referenced.
.IP REG_EESCAPE 14
Trailing
<backslash>
character in pattern.
.IP REG_ESUBREG 14
Number in \e\fIdigit\fP invalid or in error.
.IP REG_EBRACK 14
.BR \(dq[]\(dq 
imbalance.
.IP REG_EPAREN 14
.BR \(dq\e(\e)\(dq 
or
.BR \(dq()\(dq 
imbalance.
.IP REG_EBRACE 14
.BR \(dq\e{\e}\(dq 
imbalance.
.IP REG_BADBR 14
Content of
.BR \(dq\e{\e}\(dq 
invalid: not a number, number too large, more than two numbers, first
larger than second.
.IP REG_ERANGE 14
Invalid endpoint in range expression.
.IP REG_ESPACE 14
Out of memory.
.IP REG_BADRPT 14
.BR '?' ,
.BR '*' ,
or
.BR '+' 
not preceded by valid regular expression.
.P
The following shall be declared as functions and may also be defined
as macros. Function prototypes shall be provided.
.sp
.RS 4
.nf
\fB
int    regcomp(regex_t *restrict, const char *restrict, int);
size_t regerror(int, const regex_t *restrict, char *restrict, size_t);
int    regexec(const regex_t *restrict, const char *restrict, size_t,
           regmatch_t [restrict], int);
void   regfree(regex_t *);
.fi \fR
.P
.RE
.P
The implementation may define additional macros or constants using
names beginning with REG_.
.LP
.IR "The following sections are informative."
.SH "APPLICATION USAGE"
None.
.SH RATIONALE
None.
.SH "FUTURE DIRECTIONS"
None.
.SH "SEE ALSO"
.IR "\fB<sys_types.h>\fP"
.P
The System Interfaces volume of POSIX.1\(hy2008,
.IR "\fIregcomp\fR\^(\|)"
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 7, Copyright (C) 2013 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group.
(This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.unix.org/online.html .
Any typographical or formatting errors that appear
in this page are most likely
to have been introduced during the conversion of the source files to
man page format. To report such errors, see
https://www.kernel.org/doc/man-pages/reporting_bugs.html .
 |