Manual Pages for Linux CentOS command on man regfree
MyWebUniversity

Manual Pages for Linux CentOS command on man regfree

REGEX(3) Linux Programmer's Manual REGEX(3)

NAME

regcomp, regexec, regerror, regfree - POSIX regex functions SYNOPSIS

#include

#include int regcomp(regext *preg, const char *regex, int cflags); int regexec(const regext *preg, const char *string, sizet nmatch, regmatcht pmatch[], int eflags); sizet regerror(int errcode, const regext *preg, char *errbuf, sizet errbufsize); void regfree(regext *preg); DESCRIPTION POSIX regex compiling regcomp() is used to compile a regular expression into a form that is suitable for subsequent regexec() searches. regcomp() is supplied with preg, a pointer to a pattern buffer storage

area; regex, a pointer to the null-terminated string and cflags, flags used to determine the type of compilation. All regular expression searching must be done via a compiled pattern buffer, thus regexec() must always be supplied with the address of a regcomp() initialized pattern buffer.

cflags may be the bitwise-or of one or more of the following: REGEXTENDED Use POSIX Extended Regular Expression syntax when interpreting regex. If not set, POSIX Basic Regular Expression syntax is used. REGICASE Do not differentiate case. Subsequent regexec() searches using this pattern buffer will be case insensitive. REGNOSUB Do not report position of matches. The nmatch and pmatch argu‐ ments to regexec() are ignored if the pattern buffer supplied was compiled with this flag set. REGNEWLINE

Match-any-character operators don't match a newline. A nonmatching list ([^...]) not containing a newline does not match a newline.

Match-beginning-of-line operator (^) matches the empty string immediately after a newline, regardless of whether eflags, the execution flags of regexec(), contains REGNOTBOL.

Match-end-of-line operator ($) matches the empty string immedi‐ ately before a newline, regardless of whether eflags contains REGNOTEOL. POSIX regex matching

regexec() is used to match a null-terminated string against the precom‐ piled pattern buffer, preg. nmatch and pmatch are used to provide information regarding the location of any matches. eflags may be the

bitwise-or of one or both of REGNOTBOL and REGNOTEOL which cause changes in matching behavior described below. REGNOTBOL

The match-beginning-of-line operator always fails to match (but see the compilation flag REGNEWLINE above) This flag may be used when different portions of a string are passed to regexec() and the beginning of the string should not be interpreted as the beginning of the line. REGNOTEOL

The match-end-of-line operator always fails to match (but see the compilation flag REGNEWLINE above) Byte offsets Unless REGNOSUB was set for the compilation of the pattern buffer, it is possible to obtain match addressing information. pmatch must be dimensioned to have at least nmatch elements. These are filled in by regexec() with substring match addresses. The offsets of the subex‐ pression starting at the ith open parenthesis are stored in pmatch[i]. The entire regular expression's match addresses are stored in pmatch[0]. (Note that to return the offsets of N subexpression matches, nmatch must be at least N+1.) Any unused structure elements

will contain the value -1. The regmatcht structure which is the type of pmatch is defined in . typedef struct { regofft rmso; regofft rmeo; } regmatcht;

Each rmso element that is not -1 indicates the start offset of the next largest substring match within the string. The relative rmeo element indicates the end offset of the match, which is the offset of the first character after the matching text. POSIX error reporting regerror() is used to turn the error codes that can be returned by both regcomp() and regexec() into error message strings. regerror() is passed the error code, errcode, the pattern buffer, preg, a pointer to a character string buffer, errbuf, and the size of the string buffer, errbufsize. It returns the size of the errbuf required

to contain the null-terminated error message string. If both errbuf and errbufsize are nonzero, errbuf is filled in with the first

errbufsize - 1 characters of the error message and a terminating null byte ('\0'). POSIX pattern buffer freeing Supplying regfree() with a precompiled pattern buffer, preg will free the memory allocated to the pattern buffer by the compiling process, regcomp(). RETURN VALUE regcomp() returns zero for a successful compilation or an error code for failure. regexec() returns zero for a successful match or REGNOMATCH for fail‐ ure. ERRORS The following errors can be returned by regcomp(): REGBADBR Invalid use of back reference operator. REGBADPAT Invalid use of pattern operators such as group or list. REGBADRPT Invalid use of repetition operators such as using '*' as the first character. REGEBRACE

Un-matched brace interval operators. REGEBRACK

Un-matched bracket list operators. REGECOLLATE Invalid collating element. REGECTYPE Unknown character class name. REGEEND Nonspecific error. This is not defined by POSIX.2. REGEESCAPE Trailing backslash. REGEPAREN

Un-matched parenthesis group operators. REGERANGE Invalid use of the range operator, e.g., the ending point of the range occurs prior to the starting point. REGESIZE Compiled regular expression requires a pattern buffer larger than 64Kb. This is not defined by POSIX.2. REGESPACE The regex routines ran out of memory. REGESUBREG Invalid back reference to a subexpression. ATTRIBUTES For an explanation of the terms used in this section, see attributes(7). ┌─────────────────────┬───────────────┬────────────────┐ │Interface │ Attribute │ Value │ ├─────────────────────┼───────────────┼────────────────┤

│regcomp(), regexec() │ Thread safety │ MT-Safe locale │ ├─────────────────────┼───────────────┼────────────────┤

│regerror() │ Thread safety │ MT-Safe env │ ├─────────────────────┼───────────────┼────────────────┤

│regfree() │ Thread safety │ MT-Safe │ └─────────────────────┴───────────────┴────────────────┘ CONFORMING TO

POSIX.1-2001. SEE ALSO grep(1), regex(7) The glibc manual section, Regular Expression Matching COLOPHON

This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can

be found at http://www.kernel.org/doc/man-pages/.

GNU 2013-02-11 REGEX(3)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™