BSD 4_3 release
[unix-history] / usr / man / man3 / regex.3
CommitLineData
f75f1585
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
95f51977 5.\" @(#)regex.3 6.1 (Berkeley) 5/15/85
f75f1585 6.\"
95f51977 7.TH REGEX 3 "May 15, 1985"
f75f1585
KM
8.UC
9.SH NAME
10re_comp, re_exec \- regular expression handler
11.SH SYNOPSIS
f75f1585 12.B char *re_comp(s)
14c55701 13.br
f75f1585
KM
14.B char *s;
15.PP
16.B re_exec(s)
14c55701 17.br
f75f1585 18.B char *s;
f75f1585
KM
19.SH DESCRIPTION
20.I Re_comp
14c55701 21compiles a string into an internal form suitable for pattern matching.
f75f1585
KM
22.I Re_exec
23checks the argument string against the last string passed to
24.I re_comp.
25.PP
26.I Re_comp
27returns 0 if the string
28.I s
29was compiled successfully; otherwise a string containing an
30error message is returned. If
31.I re_comp
32is passed 0 or a null string, it returns without changing the currently
33compiled regular expression.
34.PP
35.I Re_exec
36returns 1 if the string
37.I s
38matches the last compiled regular expression, 0 if the string
39.I s
14c55701
KM
40failed to match the last compiled regular expression, and \-1 if the compiled
41regular expression was invalid (indicating an internal error).
f75f1585
KM
42.PP
43The strings passed to both
44.I re_comp
45and
46.I re_exec
47may have trailing or embedded newline characters;
48they are terminated by nulls.
14c55701
KM
49The regular expressions recognized are described in the manual entry for
50.IR ed (1),
51given the above difference.
f75f1585 52.SH "SEE ALSO"
14c55701 53ed(1), ex(1), egrep(1), fgrep(1), grep(1)
f75f1585
KM
54.SH DIAGNOSTICS
55.I Re_exec
14c55701 56returns \-1 for an internal error.
f75f1585
KM
57.PP
58.I Re_comp
59returns one of the following strings if an error occurs:
14c55701
KM
60.PP
61.nf
62.in +0.5i
63\fINo previous regular expression,
64Regular expression too long,
65unmatched \e(,
66missing ],
67too many \e(\e) pairs,
68unmatched \e).\fP
69.in -0.5i
70.fi