xref: /original-bsd/lib/libcompat/4.3/re_comp.3 (revision 3b6250d9)
1.\" Copyright (c) 1980, 1991 Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)re_comp.3	6.4 (Berkeley) 03/29/92
7.\"
8.Dd
9.Dt REGEX 3
10.Os
11.Sh NAME
12.Nm re_comp ,
13.Nm re_exec
14.Nd regular expression handler
15.Sh SYNOPSIS
16.Fd #include <unistd.h>
17.Ft char *
18.Fn re_comp "const char *s"
19.Ft int
20.Fn re_exec "const char *s"
21.Bf -symbolic
22This interface is made obsolete by:
23.Ef
24.Xr regexp 3 .
25.Pp
26.Sh DESCRIPTION
27The
28.Fn re_comp
29function
30compiles a string into an internal form suitable for pattern matching.
31The
32.Fn re_exec
33function
34checks the argument string against the last string passed to
35.Fn re_comp .
36.Pp
37The
38.Fn re_comp
39function
40returns 0 if the string
41.Fa s
42was compiled successfully; otherwise a string containing an
43error message is returned. If
44.Fn re_comp
45is passed 0 or a null string, it returns without changing the currently
46compiled regular expression.
47.Pp
48The
49.Fn re_exec
50function
51returns 1 if the string
52.Fa s
53matches the last compiled regular expression, 0 if the string
54.Fa s
55failed to match the last compiled regular expression, and \-1 if the compiled
56regular expression was invalid (indicating an internal error).
57.Pp
58The strings passed to both
59.Fn re_comp
60and
61.Fn re_exec
62may have trailing or embedded newline characters;
63they are terminated by
64.Dv NUL Ns s.
65The regular expressions recognized are described in the manual entry for
66.Xr ed 1 ,
67given the above difference.
68.Sh DIAGNOSTICS
69The
70.Fn re_exec
71function
72returns \-1 for an internal error.
73.Pp
74The
75.Fn re_comp
76function
77returns one of the following strings if an error occurs:
78.Bd -unfilled -offset indent
79No previous regular expression,
80Regular expression too long,
81unmatched \e(,
82missing ],
83too many \e(\e) pairs,
84unmatched \e).
85.Ed
86.Sh SEE ALSO
87.Xr ed 1 ,
88.Xr ex 1 ,
89.Xr egrep 1 ,
90.Xr fgrep 1 ,
91.Xr grep 1 ,
92.Xr regexp 3
93.Sh HISTORY
94The
95.Fn re_comp
96and
97.Fn re_exec
98functions appeared in
99.Bx 4.0 .
100