1.fp 5 B 2.de Af 3.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2 4.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9" 5.. 6.de aF 7.ie \\$3 .ft \\$1 8.el \{\ 9.ds ;G \& 10.nr ;G \\n(.f 11.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9" 12\\*(;G 13.ft \\n(;G \} 14.. 15.de L 16.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" 17.. 18.de LR 19.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" 20.. 21.de RL 22.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" 23.. 24.de EX \" start example 25.ta 1i 2i 3i 4i 5i 6i 26.PP 27.RS 28.PD 0 29.ft 5 30.nf 31.. 32.de EE \" end example 33.fi 34.ft 35.PD 36.RE 37.PP 38.. 39.TH REGEX 3 40.SH NAME 41regex \- regular expression interface 42.SH SYNOPSIS 43.EX 44#include <regex.h> 45 46int regcomp(regex_t* \fIre\fP, const char* \fIregex\fP, int \fIcflags\fP); 47int regexec(const regex_t* \fIre\fP, const char* \fIstring\fP, size_t \fInmatch\fP, regmatch_t \fIpmatch\fP[], int \fIeflags\fP); 48size_t regerror(int \fIcode\fP, const regex_t* \fIre\fP, char* \fIerrbuf\fP, size_t \fIerrbuf_size\fP); 49void regfree(regex_t* \fIre\fP); 50 51regclass_t regclass(const char* \fIstr\fP, char** \fIend\fP); 52int regaddclass(const char* \fIname\fP, regclass_t \fIclassf\fP); 53int regcollate(const char* \fIstr\fP, char** \fIend\fP, char* \fIbuf\fP, int \fIsize\fP); 54 55int regcomb(regex_t* \fIre_1\fP, regex_t* \fIre_2\fP); 56size_t regdecomp(regex_t* \fIre\fP, regflags_t \fIflags\fP, char* \fIbuf\fP, size_t \fIsize\fP); 57int regdup(regex_t* \fIre_old\fP, regex_t* \fIre_new\fP); 58regstat_t* regstat(const regex_t* \fIre\fP); 59 60regex_t* regcache(const char* \fIpattern\fP, regflags_t \fIflags\fP, int* \fIpcode\fP); 61 62int regncomp(regex_t* \fIre\fP, const char* \fIpattern\fP, size_t \fIsize\fP, regflags_t \fIflags\fP); 63int regnexec(const regex_t* \fIre\fP, const char* \fIsubject\fP, size_t \fIsize\fP, size_t \fInmatch\fP, regmatch_t* \fImatch\fP, regflags_t \fIflags\fP); 64int regrecord(const regex_t* \fIre\fP); 65int regrexec(const regex_t* \fIre\fP, const char* \fIbuf\fP, size_t \fIsize\fP, size_t \fInmatch\fP, regmatch_t* \fImatch\fP, regflags_t \fIflags\fP, int \fIsep\fP, void* \fIhandle\fP, regrecord_t \fIrecordf\fP); 66void regfatal(regex_t* \fIre\fP, int \fIlevel\fP, int \fIcode\fP); 67void regfatalpat(regex_t* \fIre\fP, int \fIlevel\fP, int \fIcode\fP, const char* \fIpattern\fP); 68 69int regsubcomp(regex_t* \fIre\fP, const char* \fIstr\fP, const regflags_t* \fImap\fP, int \fIminmatch\fP, regflags_t \fIflags\fP); 70int regsubexec(const regex_t* \fIre\fP, const char* \fIsubject\fP, size_t \fInmatch\fP, regmatch_t* match); 71int regsubflags(regex_t* \fIre\fP, const char* \fIstr\fP, char** \fIend\fP, int \fIdelim\fP, const regflags_t* \fImap\fP, int* \fIpm\fP, regflags_t* \fIpf\fP); 72void regsubfree(regex_t* \fIre\fP); 73.EE 74 75.SH DESCRIPTION 76.LR regcomp() , 77.LR regexec() , 78.LR regerror() , 79and 80.L regfree() 81are the POSIX regular expression functions. 82The remaining functions are 83.B ast 84extensions. 85.B ast 86also provides 87.I flags 88extensions to the 89.LR regcomp() , 90.LR regexec() 91functions and 92.I code 93extensions to the 94.L regerror() 95function. 96 97.PP 98.L regcache() 99maintains a cache of compiled regular expressions for patterns of size 100255 bytes or less. 101The initial cache size is 8. 102.L pattern 103and 104.L flags 105are passed to 106.L regcomp() 107with an 108.L re 109pointer maintained by 110.LR regcache() . 111.LR pcode , 112if not 0, points to the return value of the 113.L regcomp() 114call. 115If the 116.L regcomp() 117call fails, 118.L regcache() 119returns 0 and 120.L pcode 121will point to the non-zero error code. 122Do not call 123.L regfree() 124on the 125.L re 126returned by 127.LR regcache() . 128Both 129.L pattern 130and 131.L flags 132are used to match entries in the cache. 133When the cache is full the least recently used 134.L re 135is freed (via 136.LR regfree() ) 137to make space for the new pattern. 138Any 139.L re 140previously returned by 141.L regcache() 142may be freed (invalidated) on the next call to 143.LR regcache() . 144If 145.L pattern 146is longer that 255 bytes then it is still passed on to 147.LR regcomp() , 148but it will not be cached. 149If 150.L pattern 151is 0 then the cache is flushed. 152In addition, if the integer value of 153.L flags 154is greater than the current cache size, the cache size is increased 155to that integer value. 1560 is always returned when 157.L pattern 158is 0; 159.L pcode 160will point to a non-zero value on error. 161 162.SH "SEE ALSO" 163strmatch(3) 164