xref: /illumos-gate/usr/src/man/man3c/regcomp.3c (revision 7edb9f69d2426b044fa60c7a168c9eaeb12f1884)
1*7edb9f69SYuri Pankov.\" Copyright (c) 1992, 1993, 1994 Henry Spencer.
2*7edb9f69SYuri Pankov.\" Copyright (c) 1992, 1993, 1994
3*7edb9f69SYuri Pankov.\"	The Regents of the University of California.  All rights reserved.
4*7edb9f69SYuri Pankov.\"
5*7edb9f69SYuri Pankov.\" This code is derived from software contributed to Berkeley by
6*7edb9f69SYuri Pankov.\" Henry Spencer.
7*7edb9f69SYuri Pankov.\"
8*7edb9f69SYuri Pankov.\" Redistribution and use in source and binary forms, with or without
9*7edb9f69SYuri Pankov.\" modification, are permitted provided that the following conditions
10*7edb9f69SYuri Pankov.\" are met:
11*7edb9f69SYuri Pankov.\" 1. Redistributions of source code must retain the above copyright
12*7edb9f69SYuri Pankov.\"    notice, this list of conditions and the following disclaimer.
13*7edb9f69SYuri Pankov.\" 2. Redistributions in binary form must reproduce the above copyright
14*7edb9f69SYuri Pankov.\"    notice, this list of conditions and the following disclaimer in the
15*7edb9f69SYuri Pankov.\"    documentation and/or other materials provided with the distribution.
16*7edb9f69SYuri Pankov.\" 3. Neither the name of the University nor the names of its contributors
17*7edb9f69SYuri Pankov.\"    may be used to endorse or promote products derived from this software
18*7edb9f69SYuri Pankov.\"    without specific prior written permission.
19*7edb9f69SYuri Pankov.\"
20*7edb9f69SYuri Pankov.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21*7edb9f69SYuri Pankov.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22*7edb9f69SYuri Pankov.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23*7edb9f69SYuri Pankov.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24*7edb9f69SYuri Pankov.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25*7edb9f69SYuri Pankov.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26*7edb9f69SYuri Pankov.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27*7edb9f69SYuri Pankov.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28*7edb9f69SYuri Pankov.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29*7edb9f69SYuri Pankov.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30*7edb9f69SYuri Pankov.\" SUCH DAMAGE.
31*7edb9f69SYuri Pankov.\"
32*7edb9f69SYuri Pankov.\"
33*7edb9f69SYuri Pankov.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission
34*7edb9f69SYuri Pankov.\" to reproduce portions of its copyrighted documentation.
35*7edb9f69SYuri Pankov.\"
36*7edb9f69SYuri Pankov.\" Original documentation from The Open Group can be obtained online at
37c10c16deSRichard Lowe.\" http://www.opengroup.org/bookstore/.
38*7edb9f69SYuri Pankov.\"
39*7edb9f69SYuri Pankov.\" The Institute of Electrical and Electronics Engineers and The Open Group,
40*7edb9f69SYuri Pankov.\" have given us permission to reprint portions of their documentation. In the
41*7edb9f69SYuri Pankov.\" following statement, the phrase "this text" refers to portions of the system
42*7edb9f69SYuri Pankov.\" documentation.
43*7edb9f69SYuri Pankov.\"
44*7edb9f69SYuri Pankov.\" Portions of this text are reprinted and reproduced in electronic form in the
45*7edb9f69SYuri Pankov.\" Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for
46*7edb9f69SYuri Pankov.\" Information Technology -- Portable Operating System Interface (POSIX),
47*7edb9f69SYuri Pankov.\" The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the
48*7edb9f69SYuri Pankov.\" Institute of Electrical and Electronics Engineers, Inc and The Open Group.
49*7edb9f69SYuri Pankov.\"
50*7edb9f69SYuri Pankov.\" In the event of any discrepancy between these versions and the original
51*7edb9f69SYuri Pankov.\" IEEE and The Open Group Standard, the original IEEE and The Open Group
52*7edb9f69SYuri Pankov.\" Standard is the referee document.
53*7edb9f69SYuri Pankov.\"
54*7edb9f69SYuri Pankov.\" The original Standard can be obtained online at
55*7edb9f69SYuri Pankov.\" http://www.opengroup.org/unix/online.html.
56*7edb9f69SYuri Pankov.\"
57c10c16deSRichard Lowe.\" This notice shall appear on any product containing this material.
58*7edb9f69SYuri Pankov.\"
59*7edb9f69SYuri Pankov.\" The contents of this file are subject to the terms of the
60*7edb9f69SYuri Pankov.\" Common Development and Distribution License (the "License").
61*7edb9f69SYuri Pankov.\" You may not use this file except in compliance with the License.
62*7edb9f69SYuri Pankov.\"
63*7edb9f69SYuri Pankov.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
64*7edb9f69SYuri Pankov.\" or http://www.opensolaris.org/os/licensing.
65*7edb9f69SYuri Pankov.\" See the License for the specific language governing permissions
66*7edb9f69SYuri Pankov.\" and limitations under the License.
67*7edb9f69SYuri Pankov.\"
68*7edb9f69SYuri Pankov.\" When distributing Covered Code, include this CDDL HEADER in each
69*7edb9f69SYuri Pankov.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
70*7edb9f69SYuri Pankov.\" If applicable, add the following below this CDDL HEADER, with the
71*7edb9f69SYuri Pankov.\" fields enclosed by brackets "[]" replaced with your own identifying
72*7edb9f69SYuri Pankov.\" information: Portions Copyright [yyyy] [name of copyright owner]
73*7edb9f69SYuri Pankov.\"
74*7edb9f69SYuri Pankov.\"
75*7edb9f69SYuri Pankov.\" Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
76*7edb9f69SYuri Pankov.\" Portions Copyright (c) 2003, Sun Microsystems, Inc.  All Rights Reserved.
77*7edb9f69SYuri Pankov.\" Copyright 2017 Nexenta Systems, Inc.
78*7edb9f69SYuri Pankov.\"
79*7edb9f69SYuri Pankov.Dd June 14, 2017
80*7edb9f69SYuri Pankov.Dt REGCOMP 3C
81*7edb9f69SYuri Pankov.Os
82*7edb9f69SYuri Pankov.Sh NAME
83*7edb9f69SYuri Pankov.Nm regcomp ,
84*7edb9f69SYuri Pankov.Nm regexec ,
85*7edb9f69SYuri Pankov.Nm regerror ,
86*7edb9f69SYuri Pankov.Nm regfree
87*7edb9f69SYuri Pankov.Nd regular-expression library
88*7edb9f69SYuri Pankov.Sh LIBRARY
89*7edb9f69SYuri Pankov.Lb libc
90*7edb9f69SYuri Pankov.Sh SYNOPSIS
91*7edb9f69SYuri Pankov.In regex.h
92*7edb9f69SYuri Pankov.Ft int
93*7edb9f69SYuri Pankov.Fo regcomp
94*7edb9f69SYuri Pankov.Fa "regex_t *restrict preg" "const char *restrict pattern" "int cflags"
95*7edb9f69SYuri Pankov.Fc
96*7edb9f69SYuri Pankov.Ft int
97*7edb9f69SYuri Pankov.Fo regexec
98*7edb9f69SYuri Pankov.Fa "const regex_t *restrict preg" "const char *restrict string"
99*7edb9f69SYuri Pankov.Fa "size_t nmatch" "regmatch_t pmatch[restrict]" "int eflags"
100*7edb9f69SYuri Pankov.Fc
101*7edb9f69SYuri Pankov.Ft size_t
102*7edb9f69SYuri Pankov.Fo regerror
103*7edb9f69SYuri Pankov.Fa "int errcode" "const regex_t *restrict preg"
104*7edb9f69SYuri Pankov.Fa "char *restrict errbuf" "size_t errbuf_size"
105*7edb9f69SYuri Pankov.Fc
106*7edb9f69SYuri Pankov.Ft void
107*7edb9f69SYuri Pankov.Fn regfree "regex_t *preg"
108*7edb9f69SYuri Pankov.Sh DESCRIPTION
109*7edb9f69SYuri PankovThese routines implement
110*7edb9f69SYuri Pankov.St -p1003.2
111*7edb9f69SYuri Pankovregular expressions; see
112*7edb9f69SYuri Pankov.Xr regex 5 .
113*7edb9f69SYuri PankovThe
114*7edb9f69SYuri Pankov.Fn regcomp
115*7edb9f69SYuri Pankovfunction compiles an RE written as a string into an internal form,
116*7edb9f69SYuri Pankov.Fn regexec
117*7edb9f69SYuri Pankovmatches that internal form against a string and reports results,
118*7edb9f69SYuri Pankov.Fn regerror
119*7edb9f69SYuri Pankovtransforms error codes from either into human-readable messages,
120*7edb9f69SYuri Pankovand
121*7edb9f69SYuri Pankov.Fn regfree
122*7edb9f69SYuri Pankovfrees any dynamically-allocated storage used by the internal form
123*7edb9f69SYuri Pankovof an RE.
124*7edb9f69SYuri Pankov.Pp
125*7edb9f69SYuri PankovThe header
126*7edb9f69SYuri Pankov.In regex.h
127*7edb9f69SYuri Pankovdeclares two structure types,
128*7edb9f69SYuri Pankov.Ft regex_t
129*7edb9f69SYuri Pankovand
130*7edb9f69SYuri Pankov.Ft regmatch_t ,
131*7edb9f69SYuri Pankovthe former for compiled internal forms and the latter for match reporting.
132*7edb9f69SYuri PankovIt also declares the four functions, a type
133*7edb9f69SYuri Pankov.Ft regoff_t ,
134*7edb9f69SYuri Pankovand a number of constants with names starting with
135*7edb9f69SYuri Pankov.Qq Dv REG_ .
136*7edb9f69SYuri Pankov.Ss Fn regcomp
137*7edb9f69SYuri PankovThe
138*7edb9f69SYuri Pankov.Fn regcomp
139*7edb9f69SYuri Pankovfunction compiles the regular expression contained in the
140*7edb9f69SYuri Pankov.Fa pattern
141*7edb9f69SYuri Pankovstring, subject to the flags in
142*7edb9f69SYuri Pankov.Fa cflags ,
143*7edb9f69SYuri Pankovand places the results in the
144*7edb9f69SYuri Pankov.Ft regex_t
145*7edb9f69SYuri Pankovstructure pointed to by
146*7edb9f69SYuri Pankov.Fa preg .
147*7edb9f69SYuri PankovThe
148*7edb9f69SYuri Pankov.Fa cflags
149*7edb9f69SYuri Pankovargument is the bitwise OR of zero or more of the following flags:
150*7edb9f69SYuri Pankov.Bl -tag -width REG_EXTENDED
151*7edb9f69SYuri Pankov.It Dv REG_EXTENDED
152*7edb9f69SYuri PankovCompile extended regular expressions
153*7edb9f69SYuri Pankov.Pq EREs ,
154*7edb9f69SYuri Pankovrather than the basic regular expressions
155*7edb9f69SYuri Pankov.Pq BREs
156*7edb9f69SYuri Pankovthat are the default.
157*7edb9f69SYuri Pankov.It Dv REG_BASIC
158*7edb9f69SYuri PankovThis is a synonym for 0, provided as a counterpart to
159*7edb9f69SYuri Pankov.Dv REG_EXTENDED
160*7edb9f69SYuri Pankovto improve readability.
161*7edb9f69SYuri Pankov.It Dv REG_NOSPEC
162*7edb9f69SYuri PankovCompile with recognition of all special characters turned off.
163*7edb9f69SYuri PankovAll characters are thus considered ordinary, so the RE is a literal string.
164*7edb9f69SYuri PankovThis is an extension, compatible with but not specified by
165*7edb9f69SYuri Pankov.St -p1003.2 ,
166*7edb9f69SYuri Pankovand should be used with caution in software intended to be portable to other
167*7edb9f69SYuri Pankovsystems.
168*7edb9f69SYuri Pankov.Dv REG_EXTENDED
169*7edb9f69SYuri Pankovand
170*7edb9f69SYuri Pankov.Dv REG_NOSPEC
171*7edb9f69SYuri Pankovmay not be used in the same call to
172*7edb9f69SYuri Pankov.Fn regcomp .
173*7edb9f69SYuri Pankov.It Dv REG_ICASE
174*7edb9f69SYuri PankovCompile for matching that ignores upper/lower case distinctions.
175*7edb9f69SYuri PankovSee
176*7edb9f69SYuri Pankov.Xr regex 5 .
177*7edb9f69SYuri Pankov.It Dv REG_NOSUB
178*7edb9f69SYuri PankovCompile for matching that need only report success or failure,
179*7edb9f69SYuri Pankovnot what was matched.
180*7edb9f69SYuri Pankov.It Dv REG_NEWLINE
181*7edb9f69SYuri PankovCompile for newline-sensitive matching.
182*7edb9f69SYuri PankovBy default, newline is a completely ordinary character with no special
183*7edb9f69SYuri Pankovmeaning in either REs or strings.
184*7edb9f69SYuri PankovWith this flag,
185*7edb9f69SYuri Pankov.Qq [^
186*7edb9f69SYuri Pankovbracket expressions and
187*7edb9f69SYuri Pankov.Qq \&.
188*7edb9f69SYuri Pankovnever match newline,
189*7edb9f69SYuri Pankova
190*7edb9f69SYuri Pankov.Qq \&^
191*7edb9f69SYuri Pankovanchor matches the null string after any newline in the string in addition to
192*7edb9f69SYuri Pankovits normal function, and the
193*7edb9f69SYuri Pankov.Qq \&$
194*7edb9f69SYuri Pankovanchor matches the null string before any newline in the string in addition to
195*7edb9f69SYuri Pankovits normal function.
196*7edb9f69SYuri Pankov.It Dv REG_PEND
197*7edb9f69SYuri PankovThe regular expression ends, not at the first NUL, but just before the character
198*7edb9f69SYuri Pankovpointed to by the
199*7edb9f69SYuri Pankov.Va re_endp
200*7edb9f69SYuri Pankovmember of the structure pointed to by
201*7edb9f69SYuri Pankov.Fa preg .
202*7edb9f69SYuri PankovThe
203*7edb9f69SYuri Pankov.Va re_endp
204*7edb9f69SYuri Pankovmember is of type
205*7edb9f69SYuri Pankov.Vt "const char *" .
206*7edb9f69SYuri PankovThis flag permits inclusion of NULs in the RE; they are considered ordinary
207*7edb9f69SYuri Pankovcharacters.
208*7edb9f69SYuri PankovThis is an extension, compatible with but not specified by
209*7edb9f69SYuri Pankov.St -p1003.2 ,
210*7edb9f69SYuri Pankovand should be used with caution in software intended to be portable to other
211*7edb9f69SYuri Pankovsystems.
212*7edb9f69SYuri Pankov.El
213*7edb9f69SYuri Pankov.Pp
214*7edb9f69SYuri PankovWhen successful,
215*7edb9f69SYuri Pankov.Fn regcomp
216*7edb9f69SYuri Pankovreturns 0 and fills in the structure pointed to by
217*7edb9f69SYuri Pankov.Fa preg .
218*7edb9f69SYuri PankovOne member of that structure
219*7edb9f69SYuri Pankov.Po other than
220*7edb9f69SYuri Pankov.Va re_endp
221*7edb9f69SYuri Pankov.Pc
222*7edb9f69SYuri Pankovis publicized:
223*7edb9f69SYuri Pankov.Va re_nsub ,
224*7edb9f69SYuri Pankovof type
225*7edb9f69SYuri Pankov.Ft size_t ,
226*7edb9f69SYuri Pankovcontains the number of parenthesized subexpressions within the RE
227*7edb9f69SYuri Pankov.Po except that the value of this member is undefined if the
228*7edb9f69SYuri Pankov.Dv REG_NOSUB
229*7edb9f69SYuri Pankovflag was used
230*7edb9f69SYuri Pankov.Pc .
231*7edb9f69SYuri Pankov.Ss Fn regexec
232*7edb9f69SYuri PankovThe
233*7edb9f69SYuri Pankov.Fn regexec
234*7edb9f69SYuri Pankovfunction matches the compiled RE pointed to by
235*7edb9f69SYuri Pankov.Fa preg
236*7edb9f69SYuri Pankovagainst the
237*7edb9f69SYuri Pankov.Fa string ,
238*7edb9f69SYuri Pankovsubject to the flags in
239*7edb9f69SYuri Pankov.Fa eflags ,
240*7edb9f69SYuri Pankovand reports results using
241*7edb9f69SYuri Pankov.Fa nmatch ,
242*7edb9f69SYuri Pankov.Fa pmatch ,
243*7edb9f69SYuri Pankovand the returned value.
244*7edb9f69SYuri PankovThe RE must have been compiled by a previous invocation of
245*7edb9f69SYuri Pankov.Fn regcomp .
246*7edb9f69SYuri PankovThe compiled form is not altered during execution of
247*7edb9f69SYuri Pankov.Fn regexec ,
248*7edb9f69SYuri Pankovso a single compiled RE can be used simultaneously by multiple threads.
249*7edb9f69SYuri Pankov.Pp
250*7edb9f69SYuri PankovBy default, the NUL-terminated string pointed to by
251*7edb9f69SYuri Pankov.Fa string
252*7edb9f69SYuri Pankovis considered to be the text of an entire line, minus any terminating
253*7edb9f69SYuri Pankovnewline.
254*7edb9f69SYuri PankovThe
255*7edb9f69SYuri Pankov.Fa eflags
256*7edb9f69SYuri Pankovargument is the bitwise OR of zero or more of the following flags:
257*7edb9f69SYuri Pankov.Bl -tag -width REG_STARTEND
258*7edb9f69SYuri Pankov.It Dv REG_NOTBOL
259*7edb9f69SYuri PankovThe first character of the string is treated as the continuation
260*7edb9f69SYuri Pankovof a line.
261*7edb9f69SYuri PankovThis means that the anchors
262*7edb9f69SYuri Pankov.Qq \&^ ,
263*7edb9f69SYuri Pankov.Qq [[:<:]] ,
264*7edb9f69SYuri Pankovand
265*7edb9f69SYuri Pankov.Qq \e<
266*7edb9f69SYuri Pankovdo not match before it; but see
267*7edb9f69SYuri Pankov.Dv REG_STARTEND
268*7edb9f69SYuri Pankovbelow.
269*7edb9f69SYuri PankovThis does not affect the behavior of newlines under
270*7edb9f69SYuri Pankov.Dv REG_NEWLINE .
271*7edb9f69SYuri Pankov.It Dv REG_NOTEOL
272*7edb9f69SYuri PankovThe NUL terminating the string does not end a line, so the
273*7edb9f69SYuri Pankov.Qq \&$
274*7edb9f69SYuri Pankovanchor does not match before it.
275*7edb9f69SYuri PankovThis does not affect the behavior of newlines under
276*7edb9f69SYuri Pankov.Dv REG_NEWLINE .
277*7edb9f69SYuri Pankov.It Dv REG_STARTEND
278*7edb9f69SYuri PankovThe string is considered to start at
279*7edb9f69SYuri Pankov.Fa string No +
280*7edb9f69SYuri Pankov.Fa pmatch Ns [0]. Ns Fa rm_so
281*7edb9f69SYuri Pankovand to end before the byte located at
282*7edb9f69SYuri Pankov.Fa string No +
283*7edb9f69SYuri Pankov.Fa pmatch Ns [0]. Ns Fa rm_eo ,
284*7edb9f69SYuri Pankovregardless of the value of
285*7edb9f69SYuri Pankov.Fa nmatch .
286*7edb9f69SYuri PankovSee below for the definition of
287*7edb9f69SYuri Pankov.Fa pmatch
288*7edb9f69SYuri Pankovand
289*7edb9f69SYuri Pankov.Fa nmatch .
290*7edb9f69SYuri PankovThis is an extension, compatible with but not specified by
291*7edb9f69SYuri Pankov.St -p1003.2 ,
292*7edb9f69SYuri Pankovand should be used with caution in software intended to be portable to other
293*7edb9f69SYuri Pankovsystems.
294*7edb9f69SYuri Pankov.Pp
295*7edb9f69SYuri PankovWithout
296*7edb9f69SYuri Pankov.Dv REG_NOTBOL ,
297*7edb9f69SYuri Pankovthe position
298*7edb9f69SYuri Pankov.Fa rm_so
299*7edb9f69SYuri Pankovis considered the beginning of a line, such that
300*7edb9f69SYuri Pankov.Qq \&^
301*7edb9f69SYuri Pankovmatches before it, and the beginning of a word if there is a word character at
302*7edb9f69SYuri Pankovthis position, such that
303*7edb9f69SYuri Pankov.Qq [[:<:]]
304*7edb9f69SYuri Pankovand
305*7edb9f69SYuri Pankov.Qq \e<
306*7edb9f69SYuri Pankovmatch before it.
307*7edb9f69SYuri Pankov.Pp
308*7edb9f69SYuri PankovWith
309*7edb9f69SYuri Pankov.Dv REG_NOTBOL ,
310*7edb9f69SYuri Pankovthe character at position
311*7edb9f69SYuri Pankov.Fa rm_so
312*7edb9f69SYuri Pankovis treated as the continuation of a line, and if
313*7edb9f69SYuri Pankov.Fa rm_so
314*7edb9f69SYuri Pankovis greater than 0, the preceding character is taken into consideration.
315*7edb9f69SYuri PankovIf the preceding character is a newline and the regular expression was compiled
316*7edb9f69SYuri Pankovwith
317*7edb9f69SYuri Pankov.Dv REG_NEWLINE ,
318*7edb9f69SYuri Pankov.Qq ^
319*7edb9f69SYuri Pankovmatches before the string; if the preceding character is not a word character
320*7edb9f69SYuri Pankovbut the string starts with a word character,
321*7edb9f69SYuri Pankov.Qq [[:<:]]
322*7edb9f69SYuri Pankovand
323*7edb9f69SYuri Pankov.Qq \e<
324*7edb9f69SYuri Pankovmatch before the string.
325*7edb9f69SYuri Pankov.El
326*7edb9f69SYuri Pankov.Pp
327*7edb9f69SYuri PankovSee
328*7edb9f69SYuri Pankov.Xr regex 5
329*7edb9f69SYuri Pankovfor a discussion of what is matched in situations where an RE or a portion
330*7edb9f69SYuri Pankovthereof could match any of several substrings of
331*7edb9f69SYuri Pankov.Fa string .
332*7edb9f69SYuri Pankov.Pp
333*7edb9f69SYuri PankovIf
334*7edb9f69SYuri Pankov.Dv REG_NOSUB
335*7edb9f69SYuri Pankovwas specified in the compilation of the RE, or if
336*7edb9f69SYuri Pankov.Fa nmatch
337*7edb9f69SYuri Pankovis 0,
338*7edb9f69SYuri Pankov.Fn regexec
339*7edb9f69SYuri Pankovignores the
340*7edb9f69SYuri Pankov.Fa pmatch
341*7edb9f69SYuri Pankovargument
342*7edb9f69SYuri Pankov.Po but see below for the case where
343*7edb9f69SYuri Pankov.Dv REG_STARTEND
344*7edb9f69SYuri Pankovis specified
345*7edb9f69SYuri Pankov.Pc .
346*7edb9f69SYuri PankovOtherwise,
347*7edb9f69SYuri Pankov.Fa pmatch
348*7edb9f69SYuri Pankovpoints to an array of
349*7edb9f69SYuri Pankov.Fa nmatch
350*7edb9f69SYuri Pankovstructures of type
351*7edb9f69SYuri Pankov.Ft regmatch_t .
352*7edb9f69SYuri PankovSuch a structure has at least the members
353*7edb9f69SYuri Pankov.Va rm_so
354*7edb9f69SYuri Pankovand
355*7edb9f69SYuri Pankov.Va rm_eo ,
356*7edb9f69SYuri Pankovboth of type
357*7edb9f69SYuri Pankov.Ft regoff_t
358*7edb9f69SYuri Pankov.Po a signed arithmetic type at least as large as an
359*7edb9f69SYuri Pankov.Ft off_t
360*7edb9f69SYuri Pankovand a
361*7edb9f69SYuri Pankov.Ft ssize_t
362*7edb9f69SYuri Pankov.Pc ,
363*7edb9f69SYuri Pankovcontaining respectively the offset of the first character of a substring
364*7edb9f69SYuri Pankovand the offset of the first character after the end of the substring.
365*7edb9f69SYuri PankovOffsets are measured from the beginning of the
366*7edb9f69SYuri Pankov.Fa string
367*7edb9f69SYuri Pankovargument given to
368*7edb9f69SYuri Pankov.Fn regexec .
369*7edb9f69SYuri PankovAn empty substring is denoted by equal offsets, both indicating the character
370*7edb9f69SYuri Pankovfollowing the empty substring.
371*7edb9f69SYuri Pankov.Pp
372*7edb9f69SYuri PankovThe 0th member of the
373*7edb9f69SYuri Pankov.Fa pmatch
374*7edb9f69SYuri Pankovarray is filled in to indicate what substring of
375*7edb9f69SYuri Pankov.Fa string
376*7edb9f69SYuri Pankovwas matched by the entire RE.
377*7edb9f69SYuri PankovRemaining members report what substring was matched by parenthesized
378*7edb9f69SYuri Pankovsubexpressions within the RE; member
379*7edb9f69SYuri Pankov.Va i
380*7edb9f69SYuri Pankovreports subexpression
381*7edb9f69SYuri Pankov.Va i ,
382*7edb9f69SYuri Pankovwith subexpressions counted
383*7edb9f69SYuri Pankov.Pq starting at 1
384*7edb9f69SYuri Pankovby the order of their opening parentheses in the RE, left to right.
385*7edb9f69SYuri PankovUnused entries in the array
386*7edb9f69SYuri Pankov.Po corresponding either to subexpressions that did not participate in the match
387*7edb9f69SYuri Pankovat all, or to subexpressions that do not exist in the RE
388*7edb9f69SYuri Pankov.Po that is,
389*7edb9f69SYuri Pankov.Va i
390*7edb9f69SYuri Pankov>
391*7edb9f69SYuri Pankov.Fa preg Ns -> Ns Va re_nsub
392*7edb9f69SYuri Pankov.Pc
393*7edb9f69SYuri Pankov.Pc
394*7edb9f69SYuri Pankovhave both
395*7edb9f69SYuri Pankov.Va rm_so
396*7edb9f69SYuri Pankovand
397*7edb9f69SYuri Pankov.Va rm_eo
398*7edb9f69SYuri Pankovset to -1.
399*7edb9f69SYuri PankovIf a subexpression participated in the match several times,
400*7edb9f69SYuri Pankovthe reported substring is the last one it matched.
401*7edb9f69SYuri Pankov.Po Note, as an example in particular, that when the RE
402*7edb9f69SYuri Pankov.Qq (b*)+
403*7edb9f69SYuri Pankovmatches
404*7edb9f69SYuri Pankov.Qq bbb ,
405*7edb9f69SYuri Pankovthe parenthesized subexpression matches each of the three
406*7edb9f69SYuri Pankov.So Li b Sc Ns s
407*7edb9f69SYuri Pankovand then an infinite number of empty strings following the last
408*7edb9f69SYuri Pankov.Qq b ,
409*7edb9f69SYuri Pankovso the reported substring is one of the empties.
410*7edb9f69SYuri Pankov.Pc
411*7edb9f69SYuri Pankov.Pp
412*7edb9f69SYuri PankovIf
413*7edb9f69SYuri Pankov.Dv REG_STARTEND
414*7edb9f69SYuri Pankovis specified,
415*7edb9f69SYuri Pankov.Fa pmatch
416*7edb9f69SYuri Pankovmust point to at least one
417*7edb9f69SYuri Pankov.Ft regmatch_t
418*7edb9f69SYuri Pankov.Po even if
419*7edb9f69SYuri Pankov.Fa nmatch
420*7edb9f69SYuri Pankovis 0 or
421*7edb9f69SYuri Pankov.Dv REG_NOSUB
422*7edb9f69SYuri Pankovwas specified
423*7edb9f69SYuri Pankov.Pc ,
424*7edb9f69SYuri Pankovto hold the input offsets for
425*7edb9f69SYuri Pankov.Dv REG_STARTEND .
426*7edb9f69SYuri PankovUse for output is still entirely controlled by
427*7edb9f69SYuri Pankov.Fa nmatch ;
428*7edb9f69SYuri Pankovif
429*7edb9f69SYuri Pankov.Fa nmatch
430*7edb9f69SYuri Pankovis 0 or
431*7edb9f69SYuri Pankov.Dv REG_NOSUB
432*7edb9f69SYuri Pankovwas specified,
433*7edb9f69SYuri Pankovthe value of
434*7edb9f69SYuri Pankov.Fa pmatch Ns [0]
435*7edb9f69SYuri Pankovwill not be changed by a successful
436*7edb9f69SYuri Pankov.Fn regexec .
437*7edb9f69SYuri Pankov.Ss Fn regerror
438*7edb9f69SYuri PankovThe
439*7edb9f69SYuri Pankov.Fn regerror
440*7edb9f69SYuri Pankovfunction maps a non-zero
441*7edb9f69SYuri Pankov.Fa errcode
442*7edb9f69SYuri Pankovfrom either
443*7edb9f69SYuri Pankov.Fn regcomp
444c10c16deSRichard Loweor
445*7edb9f69SYuri Pankov.Fn regexec
446*7edb9f69SYuri Pankovto a human-readable, printable message.
447*7edb9f69SYuri PankovIf
448*7edb9f69SYuri Pankov.Fa preg
449*7edb9f69SYuri Pankovis non-NULL, the error code should have arisen from use of the
450*7edb9f69SYuri Pankov.Ft regex_t
451*7edb9f69SYuri Pankovpointed to by
452*7edb9f69SYuri Pankov.Fa preg ,
453*7edb9f69SYuri Pankovand if the error code came from
454*7edb9f69SYuri Pankov.Fn regcomp ,
455*7edb9f69SYuri Pankovit should have been the result from the most recent
456*7edb9f69SYuri Pankov.Fn regcomp
457*7edb9f69SYuri Pankovusing that
458*7edb9f69SYuri Pankov.Ft regex_t .
459*7edb9f69SYuri PankovThe
460*7edb9f69SYuri Pankov.Po
461*7edb9f69SYuri Pankov.Fn regerror
462*7edb9f69SYuri Pankovmay be able to supply a more detailed message using information
463*7edb9f69SYuri Pankovfrom the
464*7edb9f69SYuri Pankov.Ft regex_t .
465*7edb9f69SYuri Pankov.Pc
466*7edb9f69SYuri PankovThe
467*7edb9f69SYuri Pankov.Fn regerror
468*7edb9f69SYuri Pankovfunction places the NUL-terminated message into the buffer pointed to by
469*7edb9f69SYuri Pankov.Fa errbuf ,
470*7edb9f69SYuri Pankovlimiting the length
471*7edb9f69SYuri Pankov.Pq including the NUL
472*7edb9f69SYuri Pankovto at most
473*7edb9f69SYuri Pankov.Fa errbuf_size
474*7edb9f69SYuri Pankovbytes.
475*7edb9f69SYuri PankovIf the whole message will not fit, as much of it as will fit before the
476*7edb9f69SYuri Pankovterminating NUL is supplied.
477*7edb9f69SYuri PankovIn any case, the returned value is the size of buffer needed to hold the whole
478*7edb9f69SYuri Pankovmessage
479*7edb9f69SYuri Pankov.Pq including terminating NUL .
480*7edb9f69SYuri PankovIf
481*7edb9f69SYuri Pankov.Fa errbuf_size
482*7edb9f69SYuri Pankovis 0,
483*7edb9f69SYuri Pankov.Fa errbuf
484*7edb9f69SYuri Pankovis ignored but the return value is still correct.
485*7edb9f69SYuri Pankov.Pp
486*7edb9f69SYuri PankovIf the
487*7edb9f69SYuri Pankov.Fa errcode
488*7edb9f69SYuri Pankovgiven to
489*7edb9f69SYuri Pankov.Fn regerror
490*7edb9f69SYuri Pankovis first ORed with
491*7edb9f69SYuri Pankov.Dv REG_ITOA ,
492*7edb9f69SYuri Pankovthe
493*7edb9f69SYuri Pankov.Qq message
494*7edb9f69SYuri Pankovthat results is the printable name of the error code, e.g.
495*7edb9f69SYuri Pankov.Qq Dv REG_NOMATCH ,
496*7edb9f69SYuri Pankovrather than an explanation thereof.
497*7edb9f69SYuri PankovIf
498*7edb9f69SYuri Pankov.Fa errcode
499*7edb9f69SYuri Pankovis
500*7edb9f69SYuri Pankov.Dv REG_ATOI ,
501*7edb9f69SYuri Pankovthen
502*7edb9f69SYuri Pankov.Fa preg
503*7edb9f69SYuri Pankovshall be non-NULL and the
504*7edb9f69SYuri Pankov.Va re_endp
505*7edb9f69SYuri Pankovmember of the structure it points to must point to the printable name of an
506*7edb9f69SYuri Pankoverror code; in this case, the result in
507*7edb9f69SYuri Pankov.Fa errbuf
508*7edb9f69SYuri Pankovis the decimal digits of the numeric value of the error code
509*7edb9f69SYuri Pankov.Pq 0 if the name is not recognized .
510*7edb9f69SYuri Pankov.Dv REG_ITOA
511*7edb9f69SYuri Pankovand
512*7edb9f69SYuri Pankov.Dv REG_ATOI
513*7edb9f69SYuri Pankovare intended primarily as debugging facilities; they are extensions,
514*7edb9f69SYuri Pankovcompatible with but not specified by
515*7edb9f69SYuri Pankov.St -p1003.2 ,
516*7edb9f69SYuri Pankovand should be used with caution in software intended to be portable to other
517*7edb9f69SYuri Pankovsystems.
518*7edb9f69SYuri Pankov.Ss Fn regfree
519*7edb9f69SYuri PankovThe
520*7edb9f69SYuri Pankov.Fn regfree
521*7edb9f69SYuri Pankovfunction frees any dynamically-allocated storage associated with the compiled RE
522*7edb9f69SYuri Pankovpointed to by
523*7edb9f69SYuri Pankov.Fa preg .
524*7edb9f69SYuri PankovThe remaining
525*7edb9f69SYuri Pankov.Ft regex_t
526*7edb9f69SYuri Pankovis no longer a valid compiled RE and the effect of supplying it to
527*7edb9f69SYuri Pankov.Fn regexec
528*7edb9f69SYuri Pankovor
529*7edb9f69SYuri Pankov.Fn regerror
530*7edb9f69SYuri Pankovis undefined.
531*7edb9f69SYuri Pankov.Sh IMPLEMENTATION NOTES
532*7edb9f69SYuri PankovThere are a number of decisions that
533*7edb9f69SYuri Pankov.St -p1003.2
534*7edb9f69SYuri Pankovleaves up to the implementor,
535*7edb9f69SYuri Pankoveither by explicitly saying
536*7edb9f69SYuri Pankov.Qq undefined
537*7edb9f69SYuri Pankovor by virtue of them being forbidden by the RE grammar.
538*7edb9f69SYuri PankovThis implementation treats them as follows.
539*7edb9f69SYuri Pankov.Pp
540*7edb9f69SYuri PankovThere is no particular limit on the length of REs, except insofar as memory is
541*7edb9f69SYuri Pankovlimited.
542*7edb9f69SYuri PankovMemory usage is approximately linear in RE size, and largely insensitive
543*7edb9f69SYuri Pankovto RE complexity, except for bounded repetitions.
544*7edb9f69SYuri Pankov.Pp
545*7edb9f69SYuri PankovA backslashed character other than one specifically given a magic meaning by
546*7edb9f69SYuri Pankov.St -p1003.2
547*7edb9f69SYuri Pankov.Pq such magic meanings occur only in BREs
548*7edb9f69SYuri Pankovis taken as an ordinary character.
549*7edb9f69SYuri Pankov.Pp
550*7edb9f69SYuri PankovAny unmatched
551*7edb9f69SYuri Pankov.Qq \&[
552*7edb9f69SYuri Pankovis a
553*7edb9f69SYuri Pankov.Dv REG_EBRACK
554*7edb9f69SYuri Pankoverror.
555*7edb9f69SYuri Pankov.Pp
556*7edb9f69SYuri PankovEquivalence classes cannot begin or end bracket-expression ranges.
557*7edb9f69SYuri PankovThe endpoint of one range cannot begin another.
558*7edb9f69SYuri Pankov.Pp
559*7edb9f69SYuri Pankov.Dv RE_DUP_MAX ,
560*7edb9f69SYuri Pankovthe limit on repetition counts in bounded repetitions, is 255.
561*7edb9f69SYuri Pankov.Pp
562*7edb9f69SYuri PankovA repetition operator
563*7edb9f69SYuri Pankov.Po
564*7edb9f69SYuri Pankov.Qq \&? ,
565*7edb9f69SYuri Pankov.Qq \&* ,
566*7edb9f69SYuri Pankov.Qq \&+ ,
567*7edb9f69SYuri Pankovor bounds
568*7edb9f69SYuri Pankov.Pc
569*7edb9f69SYuri Pankovcannot follow another repetition operator.
570*7edb9f69SYuri PankovA repetition operator cannot begin an expression or subexpression
571*7edb9f69SYuri Pankovor follow
572*7edb9f69SYuri Pankov.Qq \&^
573*7edb9f69SYuri Pankovor
574*7edb9f69SYuri Pankov.Qq \&| .
575*7edb9f69SYuri Pankov.Pp
576*7edb9f69SYuri Pankov.Qq \&|
577*7edb9f69SYuri Pankovcannot appear first or last in a (sub)expression or after another
578*7edb9f69SYuri Pankov.Qq \&| ,
579*7edb9f69SYuri Pankovi.e., an operand of
580*7edb9f69SYuri Pankov.Qq \&|
581*7edb9f69SYuri Pankovcannot be an empty subexpression.
582*7edb9f69SYuri PankovAn empty parenthesized subexpression,
583*7edb9f69SYuri Pankov.Qq () ,
584*7edb9f69SYuri Pankovis legal and matches an empty (sub)string.
585*7edb9f69SYuri PankovAn empty string is not a legal RE.
586*7edb9f69SYuri Pankov.Pp
587*7edb9f69SYuri PankovA
588*7edb9f69SYuri Pankov.Qq \&{
589*7edb9f69SYuri Pankovfollowed by a digit is considered the beginning of bounds for a bounded
590*7edb9f69SYuri Pankovrepetition, which must then follow the syntax for bounds.
591*7edb9f69SYuri PankovA
592*7edb9f69SYuri Pankov.Qq \&{
593*7edb9f69SYuri Pankov.Em not
594*7edb9f69SYuri Pankovfollowed by a digit is considered an ordinary character.
595*7edb9f69SYuri Pankov.Pp
596*7edb9f69SYuri Pankov.Qq \&^
597*7edb9f69SYuri Pankovand
598*7edb9f69SYuri Pankov.Qq \&$
599*7edb9f69SYuri Pankovbeginning and ending subexpressions in BREs are anchors, not ordinary
600*7edb9f69SYuri Pankovcharacters.
601*7edb9f69SYuri Pankov.Sh RETURN VALUES
602*7edb9f69SYuri PankovOn successful completion, the
603*7edb9f69SYuri Pankov.Fn regcomp
604*7edb9f69SYuri Pankovfunction returns 0.
605c10c16deSRichard LoweOtherwise, it returns an integer value indicating an error as described in
606*7edb9f69SYuri Pankov.In regex.h ,
607*7edb9f69SYuri Pankovand the content of preg is undefined.
608*7edb9f69SYuri Pankov.Pp
609*7edb9f69SYuri PankovOn successful completion, the
610*7edb9f69SYuri Pankov.Fn regexec
611*7edb9f69SYuri Pankovfunction returns 0.
612*7edb9f69SYuri PankovOtherwise it returns
613*7edb9f69SYuri Pankov.Dv REG_NOMATCH
614*7edb9f69SYuri Pankovto indicate no match, or
615*7edb9f69SYuri Pankov.Dv REG_ENOSYS
616*7edb9f69SYuri Pankovto indicate that the function is not supported.
617*7edb9f69SYuri Pankov.Pp
618*7edb9f69SYuri PankovUpon successful completion, the
619*7edb9f69SYuri Pankov.Fn regerror
620*7edb9f69SYuri Pankovfunction returns the number of bytes needed to hold the entire generated string.
621*7edb9f69SYuri PankovOtherwise, it returns 0 to indicate that the function is not implemented.
622*7edb9f69SYuri Pankov.Pp
623*7edb9f69SYuri PankovThe
624*7edb9f69SYuri Pankov.Fn regfree
625*7edb9f69SYuri Pankovfunction returns no value.
626*7edb9f69SYuri Pankov.Pp
627*7edb9f69SYuri PankovThe following constants are defined as error return values:
628*7edb9f69SYuri Pankov.Pp
629*7edb9f69SYuri Pankov.Bl -tag -width "REG_ECOLLATE" -compact
630*7edb9f69SYuri Pankov.It Dv REG_NOMATCH
631*7edb9f69SYuri PankovThe
632*7edb9f69SYuri Pankov.Fn regexec
633*7edb9f69SYuri Pankovfunction failed to match.
634*7edb9f69SYuri Pankov.It Dv REG_BADPAT
635*7edb9f69SYuri PankovInvalid regular expression.
636*7edb9f69SYuri Pankov.It Dv REG_ECOLLATE
637*7edb9f69SYuri PankovInvalid collating element referenced.
638*7edb9f69SYuri Pankov.It Dv REG_ECTYPE
639*7edb9f69SYuri PankovInvalid character class type referenced.
640*7edb9f69SYuri Pankov.It Dv REG_EESCAPE
641*7edb9f69SYuri PankovTrailing
642*7edb9f69SYuri Pankov.Qq \&\e
643c10c16deSRichard Lowein pattern.
644*7edb9f69SYuri Pankov.It Dv REG_ESUBREG
645*7edb9f69SYuri PankovNumber in
646*7edb9f69SYuri Pankov.Qq \&\e Ns Em digit
647*7edb9f69SYuri Pankovinvalid or in error.
648*7edb9f69SYuri Pankov.It Dv REG_EBRACK
649*7edb9f69SYuri Pankov.Qq []
650*7edb9f69SYuri Pankovimbalance.
651*7edb9f69SYuri Pankov.It Dv REG_ENOSYS
652*7edb9f69SYuri PankovThe function is not supported.
653*7edb9f69SYuri Pankov.It Dv REG_EPAREN
654*7edb9f69SYuri Pankov.Qq \e(\e)
655*7edb9f69SYuri Pankovor
656*7edb9f69SYuri Pankov.Qq ()
657*7edb9f69SYuri Pankovimbalance.
658*7edb9f69SYuri Pankov.It Dv REG_EBRACE
659*7edb9f69SYuri Pankov.Qq \e{\e}
660*7edb9f69SYuri Pankovimbalance.
661*7edb9f69SYuri Pankov.It Dv REG_BADBR
662*7edb9f69SYuri PankovContent of
663*7edb9f69SYuri Pankov.Qq \e{\e}
664*7edb9f69SYuri Pankovinvalid: not a number, number too large, more than two
665*7edb9f69SYuri Pankovnumbers, first larger than second.
666*7edb9f69SYuri Pankov.It Dv REG_ERANGE
667*7edb9f69SYuri PankovInvalid endpoint in range expression.
668*7edb9f69SYuri Pankov.It Dv REG_ESPACE
669*7edb9f69SYuri PankovOut of memory.
670*7edb9f69SYuri Pankov.It Dv REG_BADRPT
671*7edb9f69SYuri Pankov.Qq \&? ,
672*7edb9f69SYuri Pankov.Qq *
673*7edb9f69SYuri Pankovor
674*7edb9f69SYuri Pankov.Qq +
675*7edb9f69SYuri Pankovnot preceded by valid regular expression.
676*7edb9f69SYuri Pankov.El
677*7edb9f69SYuri Pankov.Sh USAGE
678*7edb9f69SYuri PankovAn application could use:
679*7edb9f69SYuri Pankov.Bd -literal -offset Ds
680*7edb9f69SYuri Pankovregerror(code, preg, (char *)NULL, (size_t)0)
681*7edb9f69SYuri Pankov.Ed
682*7edb9f69SYuri Pankov.Pp
683*7edb9f69SYuri Pankovto find out how big a buffer is needed for the generated string,
684*7edb9f69SYuri Pankov.Fn malloc
685*7edb9f69SYuri Pankova buffer to hold the string, and then call
686*7edb9f69SYuri Pankov.Fn regerror
687*7edb9f69SYuri Pankovagain to get the string
688*7edb9f69SYuri Pankov.Po see
689*7edb9f69SYuri Pankov.Xr malloc 3C
690*7edb9f69SYuri Pankov.Pc .
691*7edb9f69SYuri PankovAlternately, it could allocate a fixed, static buffer that is big enough to hold
692*7edb9f69SYuri Pankovmost strings, and then use
693*7edb9f69SYuri Pankov.Fn malloc
694*7edb9f69SYuri Pankovallocate a larger buffer if it finds that this is too small.
695*7edb9f69SYuri Pankov.Sh EXAMPLES
696*7edb9f69SYuri PankovMatching string against the extended regular expression in pattern.
697*7edb9f69SYuri Pankov.Bd -literal -offset Ds
698c10c16deSRichard Lowe#include <regex.h>
699*7edb9f69SYuri Pankov
700c10c16deSRichard Lowe/*
701c10c16deSRichard Lowe* Match string against the extended regular expression in
702c10c16deSRichard Lowe* pattern, treating errors as no match.
703c10c16deSRichard Lowe*
704c10c16deSRichard Lowe* return 1 for match, 0 for no match
705c10c16deSRichard Lowe*/
706c10c16deSRichard Loweint
707c10c16deSRichard Lowematch(const char *string, char *pattern)
708c10c16deSRichard Lowe{
709c10c16deSRichard Lowe	int status;
710c10c16deSRichard Lowe	regex_t re;
711*7edb9f69SYuri Pankov
712c10c16deSRichard Lowe	if (regcomp(&re, pattern, REG_EXTENDED\||\|REG_NOSUB) != 0) {
713c10c16deSRichard Lowe		return(0);      /* report error */
714c10c16deSRichard Lowe	}
715c10c16deSRichard Lowe	status = regexec(&re, string, (size_t) 0, NULL, 0);
716c10c16deSRichard Lowe	regfree(&re);
717c10c16deSRichard Lowe	if (status != 0) {
718c10c16deSRichard Lowe		return(0);      /* report error */
719c10c16deSRichard Lowe	}
720c10c16deSRichard Lowe	return(1);
721c10c16deSRichard Lowe}
722*7edb9f69SYuri Pankov.Ed
723*7edb9f69SYuri Pankov.Pp
724*7edb9f69SYuri PankovThe following demonstrates how the
725*7edb9f69SYuri Pankov.Dv REG_NOTBOL
726*7edb9f69SYuri Pankovflag could be used with
727*7edb9f69SYuri Pankov.Fn regexec
728*7edb9f69SYuri Pankovto find all substrings in a line that match a pattern supplied by a user.
729*7edb9f69SYuri Pankov.Pq For simplicity of the example, very little error checking is done.
730*7edb9f69SYuri Pankov.Bd -literal -offset Ds
731c10c16deSRichard Lowe(void) regcomp(&re, pattern, 0);
732*7edb9f69SYuri Pankov/* this call to regexec() finds the first match on the line */
733c10c16deSRichard Loweerror = regexec(&re, &buffer[0], 1, &pm, 0);
734c10c16deSRichard Lowewhile (error == 0) {    /* while matches found */
735c10c16deSRichard Lowe	/* substring found between pm.rm_so and pm.rm_eo */
736*7edb9f69SYuri Pankov	/* This call to regexec() finds the next match */
737c10c16deSRichard Lowe	error = regexec(&re, buffer + pm.rm_eo, 1, &pm, REG_NOTBOL);
738c10c16deSRichard Lowe}
739*7edb9f69SYuri Pankov.Ed
740*7edb9f69SYuri Pankov.Sh ERRORS
741*7edb9f69SYuri PankovNo errors are defined.
742*7edb9f69SYuri Pankov.Sh CODE SET INDEPENDENCE
743*7edb9f69SYuri Pankov.Sy Enabled
744*7edb9f69SYuri Pankov.Sh INTERFACE STABILITY
745*7edb9f69SYuri Pankov.Sy Standard
746*7edb9f69SYuri Pankov.Sh MT-LEVEL
747*7edb9f69SYuri Pankov.Sy MT-Safe with exceptions
748*7edb9f69SYuri Pankov.Pp
749*7edb9f69SYuri PankovThe
750*7edb9f69SYuri Pankov.Fn regcomp
751*7edb9f69SYuri Pankovfunction can be used safely in a multithreaded application as long as
752*7edb9f69SYuri Pankov.Xr setlocale 3C
753*7edb9f69SYuri Pankovis not being called to change the locale.
754*7edb9f69SYuri Pankov.Sh SEE ALSO
755*7edb9f69SYuri Pankov.Xr attributes 5 ,
756*7edb9f69SYuri Pankov.Xr regex 5 ,
757*7edb9f69SYuri Pankov.Xr standards 5
758*7edb9f69SYuri Pankov.Pp
759*7edb9f69SYuri Pankov.St -p1003.2 ,
760*7edb9f69SYuri Pankovsections 2.8
761*7edb9f69SYuri Pankov.Pq Regular Expression Notation
762*7edb9f69SYuri Pankovand
763*7edb9f69SYuri PankovB.5
764*7edb9f69SYuri Pankov.Pq C Binding for Regular Expression Matching .
765