summaryrefslogtreecommitdiff
path: root/man0p/regex.h.0p
blob: f8da9f2b89761667893e5ed7137a343318f69ebe (plain)
1
2
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
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
.TH "<regex.h>" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" <regex.h> 
.SH NAME
regex.h \- regular expression matching types
.SH SYNOPSIS
.LP
\fB#include <regex.h>\fP
.SH DESCRIPTION
.LP
The \fI<regex.h>\fP header shall define the structures and symbolic
constants used by the \fIregcomp\fP(), \fIregexec\fP(), \fIregerror\fP(),
and \fIregfree\fP() functions.
.LP
The structure type \fBregex_t\fP shall contain at least the following
member:
.sp
.RS
.nf

\fBsize_t    re_nsub   \fP Number of parenthesized subexpressions. \fB
\fP
.fi
.RE
.LP
The type \fBsize_t\fP shall be defined as described in \fI<sys/types.h>\fP
\&.
.LP
The type \fBregoff_t\fP shall be defined as a signed integer type
that can hold the largest value that can be stored in either
a type \fBoff_t\fP or type \fBssize_t\fP. The structure type \fBregmatch_t\fP
shall contain at least the following members:
.sp
.RS
.nf

\fBregoff_t    rm_so   \fP Byte offset from start of string \fB
                    \fP to start of substring. \fB
regoff_t    rm_eo   \fP Byte offset from start of string of the \fB
                    \fP first character after the end of substring. \fB
\fP
.fi
.RE
.LP
Values for the \fIcflags\fP parameter to the \fIregcomp\fP() function
are as
follows:
.TP 7
REG_EXTENDED
Use Extended Regular Expressions.
.TP 7
REG_ICASE
Ignore case in match.
.TP 7
REG_NOSUB
Report only success or fail in \fIregexec\fP().
.TP 7
REG_NEWLINE
Change the handling of <newline>.
.sp
.LP
Values for the \fIeflags\fP parameter to the \fIregexec\fP() function
are as
follows:
.TP 7
REG_NOTBOL
The circumflex character ( \fB'^'\fP ), when taken as a special character,
does not match the beginning of
\fIstring\fP.
.TP 7
REG_NOTEOL
The dollar sign ( \fB'$'\fP ), when taken as a special character,
does not match the end of \fIstring\fP.
.sp
.LP
The following constants shall be defined as error return values:
.TP 7
REG_NOMATCH
\fIregexec\fP() failed to match.
.TP 7
REG_BADPAT
Invalid regular expression.
.TP 7
REG_ECOLLATE
Invalid collating element referenced.
.TP 7
REG_ECTYPE
Invalid character class type referenced.
.TP 7
REG_EESCAPE
Trailing \fB'\\'\fP in pattern.
.TP 7
REG_ESUBREG
Number in \\\fIdigit\fP invalid or in error.
.TP 7
REG_EBRACK
\fB"[]"\fP imbalance.
.TP 7
REG_EPAREN
\fB"\\(\\)"\fP or \fB"()"\fP imbalance.
.TP 7
REG_EBRACE
\fB"\\{\\}"\fP imbalance.
.TP 7
REG_BADBR
Content of \fB"\\{\\}"\fP invalid: not a number, number too large,
more than two numbers, first larger than second.
.TP 7
REG_ERANGE
Invalid endpoint in range expression.
.TP 7
REG_ESPACE
Out of memory.
.TP 7
REG_BADRPT
\fB'?'\fP , \fB'*'\fP , or \fB'+'\fP not preceded by valid regular
expression.
.TP 7
REG_ENOSYS
Reserved. 
.sp
.LP
The following shall be declared as functions and may also be defined
as macros. Function prototypes shall be provided.
.sp
.RS
.nf

\fBint    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 *);
\fP
.fi
.RE
.LP
The implementation may define additional macros or constants using
names beginning with REG_.
.LP
\fIThe following sections are informative.\fP
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fI<sys/types.h>\fP , the System Interfaces volume of IEEE\ Std\ 1003.1-2001,
\fIregcomp\fP(), the Shell and Utilities volume of IEEE\ Std\ 1003.1-2001
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. 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.opengroup.org/unix/online.html .