2004-11-03 13:51:07 +00:00
|
|
|
.\" Copyright (C), 1995, Graeme W. Wilford. (Wilf.)
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to make and distribute verbatim copies of this
|
|
|
|
.\" manual provided the copyright notice and this permission notice are
|
|
|
|
.\" preserved on all copies.
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to copy and distribute modified versions of this
|
|
|
|
.\" manual under the conditions for verbatim copying, provided that the
|
|
|
|
.\" entire resulting derived work is distributed under the terms of a
|
|
|
|
.\" permission notice identical to this one.
|
2007-04-12 22:42:49 +00:00
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
|
|
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
|
|
.\" responsibility for errors or omissions, or for damages resulting from
|
|
|
|
.\" the use of the information contained herein. The author(s) may not
|
|
|
|
.\" have taken the same level of care in the production of this manual,
|
|
|
|
.\" which is licensed free of charge, as they might when working
|
|
|
|
.\" professionally.
|
2007-04-12 22:42:49 +00:00
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
|
|
.\" the source, must acknowledge the copyright and authors of this work.
|
|
|
|
.\"
|
|
|
|
.\" Wed Jun 14 16:10:28 BST 1995 Wilf. (G.Wilford@ee.surrey.ac.uk)
|
|
|
|
.\" Tiny change in formatting - aeb, 950812
|
|
|
|
.\" Modified 8 May 1998 by Joseph S. Myers (jsm28@cam.ac.uk)
|
|
|
|
.\"
|
|
|
|
.\" show the synopsis section nicely
|
|
|
|
.de xx
|
|
|
|
.in \\n(INu+\\$1
|
|
|
|
.ti -\\$1
|
|
|
|
..
|
2013-02-11 21:37:04 +00:00
|
|
|
.TH REGEX 3 2013-02-11 "GNU" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NAME
|
|
|
|
regcomp, regexec, regerror, regfree \- POSIX regex functions
|
|
|
|
.SH SYNOPSIS
|
2007-12-23 08:20:39 +00:00
|
|
|
.nf
|
2004-11-03 13:51:07 +00:00
|
|
|
.B #include <sys/types.h>
|
|
|
|
.B #include <regex.h>
|
2007-12-23 08:20:39 +00:00
|
|
|
|
|
|
|
.BI "int regcomp(regex_t *" preg ", const char *" regex ", int " cflags );
|
|
|
|
|
|
|
|
.BI "int regexec(const regex_t *" preg ", const char *" string \
|
|
|
|
", size_t " nmatch ,
|
|
|
|
.BI " regmatch_t " pmatch[] ", int " eflags );
|
|
|
|
|
|
|
|
.BI "size_t regerror(int " errcode ", const regex_t *" preg ", char *" errbuf ,
|
|
|
|
.BI " size_t " errbuf_size );
|
|
|
|
|
|
|
|
.BI "void regfree(regex_t *" preg );
|
|
|
|
.fi
|
2007-05-16 17:35:34 +00:00
|
|
|
.SH DESCRIPTION
|
intro.1, time.1, _syscall.2, accept.2, brk.2, capget.2, faccessat.2, futimesat.2, gethostname.2, intro.2, ioprio_set.2, kill.2, madvise.2, mlock.2, mount.2, msgget.2, perf_event_open.2, poll.2, readv.2, sched_rr_get_interval.2, sched_setscheduler.2, select.2, select_tut.2, shmget.2, stat.2, timer_create.2, ustat.2, vfork.2, wait.2, alloca.3, atexit.3, catopen.3, crypt.3, dbopen.3, fenv.3, fopen.3, getaddrinfo_a.3, gethostbyname.3, getutent.3, intro.3, login.3, mallopt.3, queue.3, regex.3, sigpause.3, sigsetops.3, stdio.3, strftime.3, strptime.3, sysconf.3, ttyslot.3, undocumented.3, cciss.4, console_codes.4, hpsa.4, initrd.4, intro.4, rtc.4, st.4, tty_ioctl.4, wavelan.4, acct.5, charmap.5, dir_colors.5, hosts.5, intro.5, termcap.5, utmp.5, intro.6, armscii-8.7, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, ddp.7, epoll.7, glob.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, man-pages.7, man.7, math_error.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, pthreads.7, raw.7, rtnetlink.7, signal.7, socket.7, spufs.7, svipc.7, tcp.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, intro.8: Global fix: use consistent capitalization in .SS headings
Capitalization in .SS sections across pages (and sometimes even
within a single page) is wildly inconsistent. Make it consistent.
Capitalize first word in heading, but otherwise use lower case,
except where English usage (e.g., proper nouns) or programming
language requirements (e.g., identifier names) dictate otherwise.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 14:08:38 +00:00
|
|
|
.SS "POSIX regex compiling"
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR regcomp ()
|
2004-11-03 13:51:07 +00:00
|
|
|
is used to compile a regular expression into a form that is suitable
|
2007-04-12 22:42:49 +00:00
|
|
|
for subsequent
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR regexec ()
|
2004-11-03 13:51:07 +00:00
|
|
|
searches.
|
|
|
|
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR regcomp ()
|
2007-04-12 22:42:49 +00:00
|
|
|
is supplied with
|
|
|
|
.IR preg ,
|
|
|
|
a pointer to a pattern buffer storage area;
|
2004-11-03 13:51:07 +00:00
|
|
|
.IR regex ,
|
|
|
|
a pointer to the null-terminated string and
|
|
|
|
.IR cflags ,
|
|
|
|
flags used to determine the type of compilation.
|
|
|
|
|
|
|
|
All regular expression searching must be done via a compiled pattern
|
2007-04-12 22:42:49 +00:00
|
|
|
buffer, thus
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR regexec ()
|
2007-04-12 22:42:49 +00:00
|
|
|
must always be supplied with the address of a
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR regcomp ()
|
2004-11-03 13:51:07 +00:00
|
|
|
initialized pattern buffer.
|
|
|
|
|
2007-04-12 22:42:49 +00:00
|
|
|
.I cflags
|
|
|
|
may be the
|
2004-11-03 13:51:07 +00:00
|
|
|
.RB bitwise- or
|
|
|
|
of one or more of the following:
|
2007-04-12 22:42:49 +00:00
|
|
|
.TP
|
2004-11-03 13:51:07 +00:00
|
|
|
.B REG_EXTENDED
|
2007-04-12 22:42:49 +00:00
|
|
|
Use
|
2004-11-03 13:51:07 +00:00
|
|
|
.B POSIX
|
2007-04-12 22:42:49 +00:00
|
|
|
Extended Regular Expression syntax when interpreting
|
2004-11-03 13:51:07 +00:00
|
|
|
.IR regex .
|
|
|
|
If not set,
|
|
|
|
.B POSIX
|
|
|
|
Basic Regular Expression syntax is used.
|
2007-04-12 22:42:49 +00:00
|
|
|
.TP
|
2004-11-03 13:51:07 +00:00
|
|
|
.B REG_ICASE
|
2007-04-12 22:42:49 +00:00
|
|
|
Do not differentiate case.
|
|
|
|
Subsequent
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR regexec ()
|
2004-11-03 13:51:07 +00:00
|
|
|
searches using this pattern buffer will be case insensitive.
|
2007-04-12 22:42:49 +00:00
|
|
|
.TP
|
2004-11-03 13:51:07 +00:00
|
|
|
.B REG_NOSUB
|
2013-02-11 21:33:17 +00:00
|
|
|
Do not report position of matches.
|
2004-11-03 13:51:07 +00:00
|
|
|
The
|
|
|
|
.I nmatch
|
|
|
|
and
|
|
|
|
.I pmatch
|
2008-07-10 20:53:08 +00:00
|
|
|
arguments to
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR regexec ()
|
2004-11-03 13:51:07 +00:00
|
|
|
are ignored if the pattern buffer supplied was compiled with this flag set.
|
2007-04-12 22:42:49 +00:00
|
|
|
.TP
|
2004-11-03 13:51:07 +00:00
|
|
|
.B REG_NEWLINE
|
|
|
|
Match-any-character operators don't match a newline.
|
|
|
|
|
accept.2, access.2, acct.2, clock_nanosleep.2, mbind.2, mincore.2, remap_file_pages.2, sched_setscheduler.2, set_mempolicy.2, splice.2, stat.2, syslog.2, timer_create.2, timerfd_create.2, truncate.2, fenv.3, ferror.3, fflush.3, fgetwc.3, fgetws.3, flockfile.3, fputwc.3, fputws.3, fread.3, getopt.3, gets.3, getwchar.3, glob.3, iconv.3, longjmp.3, pow.3, printf.3, puts.3, putwchar.3, regex.3, rpc.3, scanf.3, setjmp.3, termios.3, unlocked_stdio.3, wcswidth.3, hd.4, rtc.4, st.4, core.5, dir_colors.5, elf.5, proc.5, arp.7, ascii.7, boot.7, bootparam.7, charsets.7, futex.7, ip.7, iso_8859-11.7, man-pages.7, man.7, mdoc.samples.7, path_resolution.7, pipe.7, posixoptions.7, unicode.7, unix.7, uri.7, utf-8.7, ld.so.8: s/non-/non/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 17:20:12 +00:00
|
|
|
A nonmatching list
|
2004-11-03 13:51:07 +00:00
|
|
|
.RB ( [^...] )
|
|
|
|
not containing a newline does not match a newline.
|
2007-04-12 22:42:49 +00:00
|
|
|
|
2004-11-03 13:51:07 +00:00
|
|
|
Match-beginning-of-line operator
|
|
|
|
.RB ( ^ )
|
|
|
|
matches the empty string immediately after a newline, regardless of
|
|
|
|
whether
|
|
|
|
.IR eflags ,
|
|
|
|
the execution flags of
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR regexec (),
|
2007-04-12 22:42:49 +00:00
|
|
|
contains
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR REG_NOTBOL .
|
|
|
|
|
2007-04-12 22:42:49 +00:00
|
|
|
Match-end-of-line operator
|
2004-11-03 13:51:07 +00:00
|
|
|
.RB ( $ )
|
|
|
|
matches the empty string immediately before a newline, regardless of
|
2007-04-12 22:42:49 +00:00
|
|
|
whether
|
2007-09-20 16:26:31 +00:00
|
|
|
.I eflags
|
2004-11-03 13:51:07 +00:00
|
|
|
contains
|
|
|
|
.BR REG_NOTEOL .
|
intro.1, time.1, _syscall.2, accept.2, brk.2, capget.2, faccessat.2, futimesat.2, gethostname.2, intro.2, ioprio_set.2, kill.2, madvise.2, mlock.2, mount.2, msgget.2, perf_event_open.2, poll.2, readv.2, sched_rr_get_interval.2, sched_setscheduler.2, select.2, select_tut.2, shmget.2, stat.2, timer_create.2, ustat.2, vfork.2, wait.2, alloca.3, atexit.3, catopen.3, crypt.3, dbopen.3, fenv.3, fopen.3, getaddrinfo_a.3, gethostbyname.3, getutent.3, intro.3, login.3, mallopt.3, queue.3, regex.3, sigpause.3, sigsetops.3, stdio.3, strftime.3, strptime.3, sysconf.3, ttyslot.3, undocumented.3, cciss.4, console_codes.4, hpsa.4, initrd.4, intro.4, rtc.4, st.4, tty_ioctl.4, wavelan.4, acct.5, charmap.5, dir_colors.5, hosts.5, intro.5, termcap.5, utmp.5, intro.6, armscii-8.7, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, ddp.7, epoll.7, glob.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, man-pages.7, man.7, math_error.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, pthreads.7, raw.7, rtnetlink.7, signal.7, socket.7, spufs.7, svipc.7, tcp.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, intro.8: Global fix: use consistent capitalization in .SS headings
Capitalization in .SS sections across pages (and sometimes even
within a single page) is wildly inconsistent. Make it consistent.
Capitalize first word in heading, but otherwise use lower case,
except where English usage (e.g., proper nouns) or programming
language requirements (e.g., identifier names) dictate otherwise.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 14:08:38 +00:00
|
|
|
.SS "POSIX regex matching"
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR regexec ()
|
2004-11-03 13:51:07 +00:00
|
|
|
is used to match a null-terminated string
|
2007-04-12 22:42:49 +00:00
|
|
|
against the precompiled pattern buffer,
|
2004-11-03 13:51:07 +00:00
|
|
|
.IR preg .
|
|
|
|
.I nmatch
|
|
|
|
and
|
|
|
|
.I pmatch
|
2007-04-12 22:42:49 +00:00
|
|
|
are used to provide information regarding the location of any matches.
|
2004-11-03 13:51:07 +00:00
|
|
|
.I eflags
|
2007-04-12 22:42:49 +00:00
|
|
|
may be the
|
2004-11-03 13:51:07 +00:00
|
|
|
.RB bitwise- or
|
2007-04-12 22:42:49 +00:00
|
|
|
of one or both of
|
2004-11-03 13:51:07 +00:00
|
|
|
.B REG_NOTBOL
|
|
|
|
and
|
2007-04-12 22:42:49 +00:00
|
|
|
.B REG_NOTEOL
|
2007-06-08 09:56:56 +00:00
|
|
|
which cause changes in matching behavior described below.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B REG_NOTBOL
|
|
|
|
The match-beginning-of-line operator always fails to match (but see the
|
|
|
|
compilation flag
|
2007-04-12 22:42:49 +00:00
|
|
|
.B REG_NEWLINE
|
2004-11-03 13:51:07 +00:00
|
|
|
above)
|
2007-04-12 22:42:49 +00:00
|
|
|
This flag may be used when different portions of a string are passed to
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR regexec ()
|
2004-11-03 13:51:07 +00:00
|
|
|
and the beginning of the string should not be interpreted as the
|
|
|
|
beginning of the line.
|
|
|
|
.TP
|
|
|
|
.B REG_NOTEOL
|
|
|
|
The match-end-of-line operator always fails to match (but see the
|
|
|
|
compilation flag
|
|
|
|
.B REG_NEWLINE
|
|
|
|
above)
|
intro.1, time.1, _syscall.2, accept.2, brk.2, capget.2, faccessat.2, futimesat.2, gethostname.2, intro.2, ioprio_set.2, kill.2, madvise.2, mlock.2, mount.2, msgget.2, perf_event_open.2, poll.2, readv.2, sched_rr_get_interval.2, sched_setscheduler.2, select.2, select_tut.2, shmget.2, stat.2, timer_create.2, ustat.2, vfork.2, wait.2, alloca.3, atexit.3, catopen.3, crypt.3, dbopen.3, fenv.3, fopen.3, getaddrinfo_a.3, gethostbyname.3, getutent.3, intro.3, login.3, mallopt.3, queue.3, regex.3, sigpause.3, sigsetops.3, stdio.3, strftime.3, strptime.3, sysconf.3, ttyslot.3, undocumented.3, cciss.4, console_codes.4, hpsa.4, initrd.4, intro.4, rtc.4, st.4, tty_ioctl.4, wavelan.4, acct.5, charmap.5, dir_colors.5, hosts.5, intro.5, termcap.5, utmp.5, intro.6, armscii-8.7, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, ddp.7, epoll.7, glob.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, man-pages.7, man.7, math_error.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, pthreads.7, raw.7, rtnetlink.7, signal.7, socket.7, spufs.7, svipc.7, tcp.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, intro.8: Global fix: use consistent capitalization in .SS headings
Capitalization in .SS sections across pages (and sometimes even
within a single page) is wildly inconsistent. Make it consistent.
Capitalize first word in heading, but otherwise use lower case,
except where English usage (e.g., proper nouns) or programming
language requirements (e.g., identifier names) dictate otherwise.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 14:08:38 +00:00
|
|
|
.SS "Byte offsets"
|
2007-04-12 22:42:49 +00:00
|
|
|
Unless
|
2004-11-03 13:51:07 +00:00
|
|
|
.B REG_NOSUB
|
|
|
|
was set for the compilation of the pattern buffer, it is possible to
|
2013-02-11 21:33:17 +00:00
|
|
|
obtain match addressing information.
|
2004-11-03 13:51:07 +00:00
|
|
|
.I pmatch
|
|
|
|
must be dimensioned to have at least
|
|
|
|
.I nmatch
|
|
|
|
elements.
|
|
|
|
These are filled in by
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR regexec ()
|
2013-02-11 21:37:04 +00:00
|
|
|
with substring match addresses.
|
|
|
|
The offsets of the subexpression starting at the
|
2013-02-11 21:33:17 +00:00
|
|
|
.IR i th
|
|
|
|
open parenthesis are stored in
|
|
|
|
.IR pmatch[i] .
|
|
|
|
The entire regular expression's match addresses are stored in
|
|
|
|
.IR pmatch[0] .
|
|
|
|
(Note that to return the offsets of
|
|
|
|
.I N
|
|
|
|
subexpression matches,
|
|
|
|
.I nmatch
|
|
|
|
must be at least
|
|
|
|
.IR N+1 .)
|
2007-04-12 22:42:49 +00:00
|
|
|
Any unused structure elements will contain the value \-1.
|
2004-11-03 13:51:07 +00:00
|
|
|
|
2007-04-12 22:42:49 +00:00
|
|
|
The
|
2007-06-23 07:56:56 +00:00
|
|
|
.I regmatch_t
|
2004-11-03 13:51:07 +00:00
|
|
|
structure which is the type of
|
|
|
|
.I pmatch
|
|
|
|
is defined in
|
2007-12-09 08:08:53 +00:00
|
|
|
.IR <regex.h> .
|
2004-11-03 13:51:07 +00:00
|
|
|
|
2007-12-19 06:16:04 +00:00
|
|
|
.in +4n
|
2007-06-23 07:56:56 +00:00
|
|
|
.nf
|
|
|
|
typedef struct {
|
|
|
|
regoff_t rm_so;
|
|
|
|
regoff_t rm_eo;
|
|
|
|
} regmatch_t;
|
|
|
|
.fi
|
2007-12-19 06:16:04 +00:00
|
|
|
.in
|
2004-11-03 13:51:07 +00:00
|
|
|
|
2007-04-12 22:42:49 +00:00
|
|
|
Each
|
2004-11-03 13:51:07 +00:00
|
|
|
.I rm_so
|
2005-06-15 14:10:23 +00:00
|
|
|
element that is not \-1 indicates the start offset of the next largest
|
2007-04-12 22:42:49 +00:00
|
|
|
substring match within the string.
|
|
|
|
The relative
|
|
|
|
.I rm_eo
|
2008-05-06 11:21:26 +00:00
|
|
|
element indicates the end offset of the match,
|
|
|
|
which is the offset of the first character after the matching text.
|
intro.1, time.1, _syscall.2, accept.2, brk.2, capget.2, faccessat.2, futimesat.2, gethostname.2, intro.2, ioprio_set.2, kill.2, madvise.2, mlock.2, mount.2, msgget.2, perf_event_open.2, poll.2, readv.2, sched_rr_get_interval.2, sched_setscheduler.2, select.2, select_tut.2, shmget.2, stat.2, timer_create.2, ustat.2, vfork.2, wait.2, alloca.3, atexit.3, catopen.3, crypt.3, dbopen.3, fenv.3, fopen.3, getaddrinfo_a.3, gethostbyname.3, getutent.3, intro.3, login.3, mallopt.3, queue.3, regex.3, sigpause.3, sigsetops.3, stdio.3, strftime.3, strptime.3, sysconf.3, ttyslot.3, undocumented.3, cciss.4, console_codes.4, hpsa.4, initrd.4, intro.4, rtc.4, st.4, tty_ioctl.4, wavelan.4, acct.5, charmap.5, dir_colors.5, hosts.5, intro.5, termcap.5, utmp.5, intro.6, armscii-8.7, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, ddp.7, epoll.7, glob.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, man-pages.7, man.7, math_error.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, pthreads.7, raw.7, rtnetlink.7, signal.7, socket.7, spufs.7, svipc.7, tcp.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, intro.8: Global fix: use consistent capitalization in .SS headings
Capitalization in .SS sections across pages (and sometimes even
within a single page) is wildly inconsistent. Make it consistent.
Capitalize first word in heading, but otherwise use lower case,
except where English usage (e.g., proper nouns) or programming
language requirements (e.g., identifier names) dictate otherwise.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 14:08:38 +00:00
|
|
|
.SS "POSIX error reporting"
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR regerror ()
|
2007-04-12 22:42:49 +00:00
|
|
|
is used to turn the error codes that can be returned by both
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR regcomp ()
|
2004-11-03 13:51:07 +00:00
|
|
|
and
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR regexec ()
|
2004-11-03 13:51:07 +00:00
|
|
|
into error message strings.
|
|
|
|
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR regerror ()
|
2004-11-03 13:51:07 +00:00
|
|
|
is passed the error code,
|
|
|
|
.IR errcode ,
|
|
|
|
the pattern buffer,
|
|
|
|
.IR preg ,
|
|
|
|
a pointer to a character string buffer,
|
|
|
|
.IR errbuf ,
|
|
|
|
and the size of the string buffer,
|
|
|
|
.IR errbuf_size .
|
|
|
|
It returns the size of the
|
|
|
|
.I errbuf
|
2007-04-12 22:42:49 +00:00
|
|
|
required to contain the null-terminated error message string.
|
|
|
|
If both
|
2004-11-03 13:51:07 +00:00
|
|
|
.I errbuf
|
|
|
|
and
|
|
|
|
.I errbuf_size
|
intro.1, time.1, adjtimex.2, capget.2, eventfd.2, fcntl.2, getrlimit.2, getsockopt.2, gettimeofday.2, intro.2, ioctl_list.2, ioperm.2, mlock.2, pivot_root.2, poll.2, prctl.2, ptrace.2, sched_setscheduler.2, select_tut.2, semget.2, sigaltstack.2, signalfd.2, sysctl.2, timer_settime.2, timerfd_create.2, wait.2, CPU_SET.3, argz_add.3, assert_perror.3, atexit.3, backtrace.3, bcmp.3, clearenv.3, ctime.3, dl_iterate_phdr.3, dlopen.3, ecvt.3, errno.3, error.3, ether_aton.3, exit.3, fenv.3, ferror.3, finite.3, flockfile.3, fnmatch.3, fpathconf.3, fpclassify.3, ftime.3, ftok.3, ftw.3, fwide.3, getaddrinfo.3, gethostbyname.3, getlogin.3, getnameinfo.3, getnetent.3, getopt.3, getprotoent.3, getrpcent.3, getservent.3, glob.3, hsearch.3, inet.3, isalpha.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, longjmp.3, lsearch.3, malloc.3, matherr.3, mblen.3, mbsinit.3, mbtowc.3, on_exit.3, printf.3, pthread_attr_init.3, pthread_attr_setaffinity_np.3, pthread_attr_setdetachstate.3, pthread_attr_setguardsize.3, pthread_attr_setinheritsched.3, pthread_attr_setschedparam.3, pthread_attr_setschedpolicy.3, pthread_attr_setscope.3, pthread_attr_setstack.3, pthread_attr_setstackaddr.3, pthread_attr_setstacksize.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_equal.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setaffinity_np.3, pthread_setcancelstate.3, pthread_setconcurrency.3, pthread_setschedparam.3, pthread_setschedprio.3, ptsname.3, putenv.3, putgrent.3, raise.3, rcmd.3, regex.3, rexec.3, rpc.3, rpmatch.3, rtnetlink.3, scandir.3, sem_init.3, setaliasent.3, setbuf.3, setenv.3, setjmp.3, signbit.3, stdio_ext.3, strtod.3, strtol.3, strtoul.3, system.3, termios.3, timeradd.3, tzset.3, ualarm.3, wctomb.3, xdr.3, st.4, tty_ioctl.4, core.5, elf.5, proc.5, bootparam.7, capabilities.7, icmp.7, ip.7, ipv6.7, math_error.7, mdoc.samples.7, mq_overview.7, pthreads.7, raw.7, regex.7, socket.7, tcp.7, tzselect.8: Global fix: s/non-zero/nonzero/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 16:40:55 +00:00
|
|
|
are nonzero,
|
2004-11-03 13:51:07 +00:00
|
|
|
.I errbuf
|
2007-04-12 22:42:49 +00:00
|
|
|
is filled in with the first
|
2005-07-06 08:00:30 +00:00
|
|
|
.I "errbuf_size \- 1"
|
2011-09-27 03:09:31 +00:00
|
|
|
characters of the error message and a terminating null byte (\(aq\\0\(aq).
|
intro.1, time.1, _syscall.2, accept.2, brk.2, capget.2, faccessat.2, futimesat.2, gethostname.2, intro.2, ioprio_set.2, kill.2, madvise.2, mlock.2, mount.2, msgget.2, perf_event_open.2, poll.2, readv.2, sched_rr_get_interval.2, sched_setscheduler.2, select.2, select_tut.2, shmget.2, stat.2, timer_create.2, ustat.2, vfork.2, wait.2, alloca.3, atexit.3, catopen.3, crypt.3, dbopen.3, fenv.3, fopen.3, getaddrinfo_a.3, gethostbyname.3, getutent.3, intro.3, login.3, mallopt.3, queue.3, regex.3, sigpause.3, sigsetops.3, stdio.3, strftime.3, strptime.3, sysconf.3, ttyslot.3, undocumented.3, cciss.4, console_codes.4, hpsa.4, initrd.4, intro.4, rtc.4, st.4, tty_ioctl.4, wavelan.4, acct.5, charmap.5, dir_colors.5, hosts.5, intro.5, termcap.5, utmp.5, intro.6, armscii-8.7, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, ddp.7, epoll.7, glob.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, man-pages.7, man.7, math_error.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, pthreads.7, raw.7, rtnetlink.7, signal.7, socket.7, spufs.7, svipc.7, tcp.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, intro.8: Global fix: use consistent capitalization in .SS headings
Capitalization in .SS sections across pages (and sometimes even
within a single page) is wildly inconsistent. Make it consistent.
Capitalize first word in heading, but otherwise use lower case,
except where English usage (e.g., proper nouns) or programming
language requirements (e.g., identifier names) dictate otherwise.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 14:08:38 +00:00
|
|
|
.SS "POSIX pattern buffer freeing"
|
2007-04-12 22:42:49 +00:00
|
|
|
Supplying
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR regfree ()
|
2004-11-03 13:51:07 +00:00
|
|
|
with a precompiled pattern buffer,
|
|
|
|
.I preg
|
|
|
|
will free the memory allocated to the pattern buffer by the compiling
|
|
|
|
process,
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR regcomp ().
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "RETURN VALUE"
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR regcomp ()
|
2004-11-03 13:51:07 +00:00
|
|
|
returns zero for a successful compilation or an error code for failure.
|
|
|
|
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR regexec ()
|
2007-04-12 22:42:49 +00:00
|
|
|
returns zero for a successful match or
|
2004-11-03 13:51:07 +00:00
|
|
|
.B REG_NOMATCH
|
|
|
|
for failure.
|
|
|
|
.SH ERRORS
|
2007-04-12 22:42:49 +00:00
|
|
|
The following errors can be returned by
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR regcomp ():
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B REG_BADBR
|
|
|
|
Invalid use of back reference operator.
|
|
|
|
.TP
|
|
|
|
.B REG_BADPAT
|
|
|
|
Invalid use of pattern operators such as group or list.
|
|
|
|
.TP
|
|
|
|
.B REG_BADRPT
|
2008-06-09 15:49:35 +00:00
|
|
|
Invalid use of repetition operators such as using \(aq*\(aq
|
2004-11-03 13:51:07 +00:00
|
|
|
as the first character.
|
|
|
|
.TP
|
|
|
|
.B REG_EBRACE
|
|
|
|
Un-matched brace interval operators.
|
|
|
|
.TP
|
|
|
|
.B REG_EBRACK
|
|
|
|
Un-matched bracket list operators.
|
|
|
|
.TP
|
|
|
|
.B REG_ECOLLATE
|
|
|
|
Invalid collating element.
|
|
|
|
.TP
|
|
|
|
.B REG_ECTYPE
|
|
|
|
Unknown character class name.
|
|
|
|
.TP
|
|
|
|
.B REG_EEND
|
2013-02-11 21:45:27 +00:00
|
|
|
Nonspecific error.
|
2007-04-12 22:42:49 +00:00
|
|
|
This is not defined by POSIX.2.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B REG_EESCAPE
|
|
|
|
Trailing backslash.
|
|
|
|
.TP
|
|
|
|
.B REG_EPAREN
|
|
|
|
Un-matched parenthesis group operators.
|
|
|
|
.TP
|
|
|
|
.B REG_ERANGE
|
2007-10-03 19:53:06 +00:00
|
|
|
Invalid use of the range operator, e.g., the ending point of the range
|
2004-11-03 13:51:07 +00:00
|
|
|
occurs prior to the starting point.
|
|
|
|
.TP
|
|
|
|
.B REG_ESIZE
|
|
|
|
Compiled regular expression requires a pattern buffer larger than 64Kb.
|
|
|
|
This is not defined by POSIX.2.
|
|
|
|
.TP
|
|
|
|
.B REG_ESPACE
|
|
|
|
The regex routines ran out of memory.
|
|
|
|
.TP
|
|
|
|
.B REG_ESUBREG
|
|
|
|
Invalid back reference to a subexpression.
|
|
|
|
.SH "CONFORMING TO"
|
2006-08-03 13:57:30 +00:00
|
|
|
POSIX.1-2001.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "SEE ALSO"
|
2007-05-27 21:40:05 +00:00
|
|
|
.BR grep (1),
|
2012-09-23 14:39:42 +00:00
|
|
|
.BR regex (7)
|
2012-06-10 18:35:16 +00:00
|
|
|
.br
|
|
|
|
The glibc manual section,
|
|
|
|
.I "Regular Expression Matching"
|