'\" et .TH regex.h "0P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual" .\" .SH PROLOG This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. .\" .SH NAME regex.h \(em regular expression matching types .SH SYNOPSIS .LP .nf #include .fi .SH DESCRIPTION The .IR header shall define the structures and symbolic constants used by the \fIregcomp\fR(), \fIregexec\fR(), \fIregerror\fR(), and \fIregfree\fR() functions. .P The .IR header shall define the .BR regex_t structure type, which shall include at least the following member: .sp .RS 4 .nf size_t re_nsub \fRNumber of parenthesized subexpressions.\fR .fi .P .RE .P The .IR header shall define the .BR size_t type as described in .IR . .P The .IR header shall define the .BR regoff_t type as a signed integer type that can hold the largest value that can be stored in either a .BR ptrdiff_t type or a .BR ssize_t type. .P The .IR header shall define the .BR regmatch_t structure type, which shall include at least the following members: .sp .RS 4 .nf regoff_t rm_so \fRByte offset from start of string\fR \fRto start of substring.\fR regoff_t rm_eo \fRByte offset from start of string of the\fR \fRfirst character after the end of substring.\fR .fi .P .RE .P The .IR header shall define the following symbolic constants for the .IR cflags parameter to the \fIregcomp\fR() function: .IP REG_EXTENDED 14 Use Extended Regular Expressions. .IP REG_ICASE 14 Ignore case in match. .IP REG_NOSUB 14 Report only success or fail in \fIregexec\fR(). .IP REG_NEWLINE 14 Change the handling of . .P The .IR header shall define the following symbolic constants for the .IR eflags parameter to the \fIregexec\fR() function: .IP REG_NOTBOL 14 The character (\c .BR '\(ha' ), when taken as a special character, does not match the beginning of .IR string . .IP REG_NOTEOL 14 The (\c .BR '$' ), when taken as a special character, does not match the end of .IR string . .P The .IR header shall define the following symbolic constants as error return values: .IP REG_NOMATCH 14 \fIregexec\fR() failed to match. .IP REG_BADPAT 14 Invalid regular expression. .IP REG_ECOLLATE 14 Invalid collating element referenced. .IP REG_ECTYPE 14 Invalid character class type referenced. .IP REG_EESCAPE 14 Trailing character in pattern. .IP REG_ESUBREG 14 Number in \e\fIdigit\fP invalid or in error. .IP REG_EBRACK 14 .BR \(dq[]\(dq imbalance. .IP REG_EPAREN 14 .BR \(dq\e(\e)\(dq or .BR \(dq()\(dq imbalance. .IP REG_EBRACE 14 .BR \(dq\e{\e}\(dq imbalance. .IP REG_BADBR 14 Content of .BR \(dq\e{\e}\(dq invalid: not a number, number too large, more than two numbers, first larger than second. .IP REG_ERANGE 14 Invalid endpoint in range expression. .IP REG_ESPACE 14 Out of memory. .IP REG_BADRPT 14 .BR '?' , .BR '*' , or .BR '+' not preceded by valid regular expression. .P The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided. .sp .RS 4 .nf int regcomp(regex_t *restrict, const char *restrict, int); size_t regerror(int, const regex_t *restrict, char *restrict, size_t); int regexec(const regex_t *restrict, const char *restrict, size_t, regmatch_t [restrict], int); void regfree(regex_t *); .fi .P .RE .P The implementation may define additional macros or constants using names beginning with REG_. .LP .IR "The following sections are informative." .SH "APPLICATION USAGE" None. .SH RATIONALE None. .SH "FUTURE DIRECTIONS" None. .SH "SEE ALSO" .IR "\fB\fP" .P The System Interfaces volume of POSIX.1\(hy2017, .IR "\fIregcomp\fR\^(\|)" .\" .SH COPYRIGHT Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . .PP Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .