|
|
1.1 ! root 1: .TH REGEXP 3 ! 2: .CT 2 data_man ! 3: .SH NAME ! 4: regcomp, regexec, regsub, regerror \(mi regular expression ! 5: .SH SYNOPSIS ! 6: .nf ! 7: .B #include <regexp.h> ! 8: .PP ! 9: .B regexp *regcomp(exp) ! 10: .B char *exp; ! 11: .PP ! 12: .B int regexec(prog, string, match, msize) ! 13: .B regexp *prog; ! 14: .B char *string; ! 15: .B regsubexp *match; ! 16: .B int msize; ! 17: .PP ! 18: .B void regsub(source, dest, match, msize) ! 19: .B char *source, *dest; ! 20: .B regsubexp *match; ! 21: .B int msize; ! 22: .PP ! 23: .B void regerror(msg) ! 24: .B char *msg; ! 25: .fi ! 26: .SH DESCRIPTION ! 27: .I Regcomp ! 28: compiles a ! 29: regular expression and returns ! 30: a pointer to a compiled regular expression. ! 31: The space is allocated by ! 32: .IR malloc (3) ! 33: and may be released by ! 34: .I free. ! 35: Regular expressions are as in ! 36: .IR re (3) ! 37: except that newlines are not operators and back-references (with ! 38: \fB\e\fIn\fR) are not supported. ! 39: .PP ! 40: .I Regexec ! 41: matches a null-terminated ! 42: .I string ! 43: against the compiled regular expression in ! 44: .I prog. ! 45: If it matches, ! 46: .I regexec ! 47: returns a non-zero value and fills in the array ! 48: .I match ! 49: with character pointers to the substrings of ! 50: .I string ! 51: that correspond to the ! 52: parenthesized subexpressions of ! 53: .IR exp : ! 54: .BI match[ i ].sp ! 55: points to the beginning and ! 56: .BI match[ i ].ep ! 57: points just beyond ! 58: the end of the ! 59: .IR i th ! 60: substring. ! 61: (Subexpression ! 62: .I i ! 63: begins at the ! 64: .IR i th ! 65: left parenthesis, counting from 1.) ! 66: Pointers in ! 67: .B match[0] ! 68: pick out the substring that corresponds to ! 69: the whole regular expression. ! 70: Unused elements of ! 71: .I match ! 72: are filled with zeros. ! 73: Matches involving ! 74: .LR * , ! 75: .LR + , ! 76: and ! 77: .L ? ! 78: are extended as far as possible. ! 79: The number of array elements in ! 80: .I match ! 81: is given by ! 82: .I msize. ! 83: The structure of elements of ! 84: .I match ! 85: is: ! 86: .IP ! 87: .EX ! 88: typedef struct { ! 89: char *sp; ! 90: char *ep; ! 91: } regsubexp; ! 92: .EE ! 93: .LP ! 94: .I Regsub ! 95: places in ! 96: .I dest ! 97: a substitution instance of ! 98: .I source ! 99: in the context of the last ! 100: .I regexec ! 101: performed using ! 102: .I match. ! 103: Each instance of ! 104: .BI \e n , ! 105: where ! 106: .I n ! 107: is a digit, is replaced by the ! 108: string delimited by ! 109: .BI match[ n ].sp ! 110: and ! 111: .BI match[ n ].ep . ! 112: Each instance of ! 113: .L & ! 114: is replaced by the string delimited by ! 115: .B match[0].sp ! 116: and ! 117: .BR match[0].ep . ! 118: .LP ! 119: .I Regerror, ! 120: called whenever an error is detected in ! 121: .I regcomp, ! 122: .I regexec, ! 123: or ! 124: .I regsub, ! 125: writes the string ! 126: .I msg ! 127: on the standard error file and exits. ! 128: .I Regerror ! 129: can be replaced to perform ! 130: special error processing. ! 131: .SH "SEE ALSO" ! 132: .IR gre (1), ! 133: .IR re (3), ! 134: .IR expr (1) ! 135: .SH DIAGNOSTICS ! 136: .I Regcomp ! 137: returns ! 138: .B (regexp *)0 ! 139: for an illegal expression ! 140: or other failure. ! 141: .I Regexec ! 142: returns 0 ! 143: if ! 144: .I string ! 145: is not accepted.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.