1*61241Sbostic.\" Copyright (c) 1980, 1991, 1993 2*61241Sbostic.\" The Regents of the University of California. All rights reserved. 320406Smckusick.\" 448349Scael.\" %sccs.include.redist.man% 520406Smckusick.\" 6*61241Sbostic.\" @(#)re_comp.3 8.1 (Berkeley) 06/04/93 748349Scael.\" 848349Scael.Dd 955836Sbostic.Dt RE_COMP 3 1048349Scael.Os 1148349Scael.Sh NAME 1248349Scael.Nm re_comp , 1348349Scael.Nm re_exec 1448349Scael.Nd regular expression handler 1548349Scael.Sh SYNOPSIS 1648349Scael.Fd #include <unistd.h> 1748349Scael.Ft char * 1848349Scael.Fn re_comp "const char *s" 1948349Scael.Ft int 2048349Scael.Fn re_exec "const char *s" 2155836Sbostic.Sh DESCRIPTION 2255836SbosticThis interface is made obsolete by 2355836Sbostic.Xr regex 3 . 2453072Sbostic.Pp 2548349ScaelThe 2648349Scael.Fn re_comp 2748349Scaelfunction 2820407Smckusickcompiles a string into an internal form suitable for pattern matching. 2948349ScaelThe 3048349Scael.Fn re_exec 3148349Scaelfunction 3220406Smckusickchecks the argument string against the last string passed to 3348349Scael.Fn re_comp . 3448349Scael.Pp 3548349ScaelThe 3648349Scael.Fn re_comp 3748349Scaelfunction 3820406Smckusickreturns 0 if the string 3948349Scael.Fa s 4020406Smckusickwas compiled successfully; otherwise a string containing an 4120406Smckusickerror message is returned. If 4248349Scael.Fn re_comp 4320406Smckusickis passed 0 or a null string, it returns without changing the currently 4420406Smckusickcompiled regular expression. 4548349Scael.Pp 4648349ScaelThe 4748349Scael.Fn re_exec 4848349Scaelfunction 4920406Smckusickreturns 1 if the string 5048349Scael.Fa s 5120406Smckusickmatches the last compiled regular expression, 0 if the string 5248349Scael.Fa s 5320407Smckusickfailed to match the last compiled regular expression, and \-1 if the compiled 5420407Smckusickregular expression was invalid (indicating an internal error). 5548349Scael.Pp 5620406SmckusickThe strings passed to both 5748349Scael.Fn re_comp 5820406Smckusickand 5948349Scael.Fn re_exec 6020406Smckusickmay have trailing or embedded newline characters; 6148349Scaelthey are terminated by 6248349Scael.Dv NUL Ns s. 6320407SmckusickThe regular expressions recognized are described in the manual entry for 6448349Scael.Xr ed 1 , 6520407Smckusickgiven the above difference. 6648349Scael.Sh DIAGNOSTICS 6748349ScaelThe 6848349Scael.Fn re_exec 6948349Scaelfunction 7020407Smckusickreturns \-1 for an internal error. 7148349Scael.Pp 7248349ScaelThe 7348349Scael.Fn re_comp 7448349Scaelfunction 7520406Smckusickreturns one of the following strings if an error occurs: 7648349Scael.Bd -unfilled -offset indent 7748349ScaelNo previous regular expression, 7820407SmckusickRegular expression too long, 7920407Smckusickunmatched \e(, 8020407Smckusickmissing ], 8120407Smckusicktoo many \e(\e) pairs, 8248349Scaelunmatched \e). 8348349Scael.Ed 8448349Scael.Sh SEE ALSO 8548349Scael.Xr ed 1 , 8648349Scael.Xr ex 1 , 8748349Scael.Xr egrep 1 , 8848349Scael.Xr fgrep 1 , 8948349Scael.Xr grep 1 , 9055836Sbostic.Xr regex 3 9148349Scael.Sh HISTORY 9248349ScaelThe 9348349Scael.Fn re_comp 9448349Scaeland 9548349Scael.Fn re_exec 9648349Scaelfunctions appeared in 9748349Scael.Bx 4.0 . 98