Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
regcomp(3)
Edit
PageHistory
Diff
Info
LikePages
REGCOMP !!!REGCOMP NAME SYNOPSIS POSIX REGEX COMPILING POSIX REGEX MATCHING POSIX ERROR REPORTING POSIX PATTERN BUFFER FREEING RETURN VALUE ERRORS CONFORMING TO SEE ALSO ---- !!NAME regcomp, regexec, regerror, regfree - POSIX regex functions !!SYNOPSIS __#include __ #include __ __int regcomp(regex_t *__''preg''__, const char *__''regex''__, int__ ''cflags''__);__ __int regexec(const regex_t *__''preg''__, const char *__''string''__, size_t__ ''nmatch''__, regmatch_t__ ''pmatch[[]''__, int__ ''eflags''__);__ __size_t regerror(int__ ''errcode''__, const regex_t *__''preg''__, char *__''errbuf''__, size_t__ ''errbuf_size''__);__ __void regfree(regex_t *__''preg''__);__ !!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__ initialised pattern buffer. ''cflags'' may be the bitwise-__or__ of one or more of the following: __REG_EXTENDED__ Use __POSIX__ Extended Regular Expression syntax when interpreting ''regex''. If not set, __POSIX__ Basic Regular Expression syntax is used. __REG_ICASE__ Do not differentiate case. Subsequent __regexec__ searches using this pattern buffer will be case insensitive. __REG_NOSUB__ Support for substring addressing of matches is not required. The ''nmatch'' and ''pmatch'' parameters to __regexec__ are ignored if the pattern buffer supplied was compiled with this flag set. __REG_NEWLINE__ Match-any-character operators don't match a newline. A non-matching 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 __REG_NOTBOL__. Match-end-of-line operator (__$__) matches the empty string immediately before a newline, regardless of whether ''eflags'' contains __REG_NOTEOL__. !!POSIX REGEX MATCHING __regexec__ is used to match a null-terminated string against the precompiled 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 __REG_NOTBOL__ and __REG_NOTEOL__ which cause changes in matching behaviour described below. __REG_NOTBOL__ The match-beginning-of-line operator always fails to match (but see the compilation flag __REG_NEWLINE__ 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. __REG_NOTEOL__ The match-end-of-line operator always fails to match (but see the compilation flag __REG_NEWLINE__ above) __BYTE OFFSETS__ Unless __REG_NOSUB__ was set for the compilation of the pattern buffer, it is possible to obtain substring match addressing information. ''pmatch'' must be dimensioned to have at least ''nmatch'' elements. These are filled in by __regexec__ with substring match addresses. Any unused structure elements will contain the value -1. The __regmatch_t__ structure which is the type of ''pmatch'' is defined in ''regex.h''. __typedef struct { regoff_t__ ''rm_so''__; regoff_t__ ''rm_eo''__; } regmatch_t;__ Each ''rm_so'' element that is not -1 indicates the start offset of the next largest substring match within the string. The relative ''rm_eo'' element indicates the end offset of the match. !!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, ''errbuf_size''. It returns the size of the ''errbuf'' required to contain the null-terminated error message string. If both ''errbuf'' and ''errbuf_size'' are non-zero, ''errbuf'' is filled in with the first ''errbuf_size - 1'' characters of the error message and a terminating null. !!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 __REG_NOMATCH__ for failure. !!ERRORS The following errors can be returned by __regcomp__: __REG_BADRPT__ Invalid use of repetition operators such as using `__*__' as the first character. __REG_BADBR__ Invalid use of back reference operator. __REG_EBRACE__ Un-matched brace interval operators. __REG_EBRACK__ Un-matched bracket list operators. __REG_ERANGE__ Invalid use of the range operator, eg. the ending point of the range occurs prior to the starting point. __REG_ECTYPE__ Unknown character class name. __REG_ECOLLATE__ Invalid collating element. __REG_EPAREN__ Un-matched parenthesis group operators. __REG_ESUBREG__ Invalid back reference to a subexpression. __REG_EEND__ Non specific error. This is not defined by POSIX.2. __REG_EESCAPE__ Trailing backslash. __REG_BADPAT__ Invalid use of pattern operators such as group or list. __REG_ESIZE__ Compiled regular expression requires a pattern buffer larger than 64Kb. This is not defined by POSIX.2. __REG_ESPACE__ The regex routines ran out of memory. !!CONFORMING TO POSIX.2 !!SEE ALSO regex(7), __GNU regex manual__ ----
2 pages link to
regcomp(3)
:
Man3r
fortune(6)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.