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