Node:Matching POSIX Regexps, Next:Regexp Subexpressions, Previous:Flags for POSIX Regexps, Up:Regular Expressions
Once you have compiled a regular expression, as described in POSIX Regexp Compilation, you can match it against strings using
regexec
. A match anywhere inside the string counts as success,
unless the regular expression contains anchor characters (^
or
$
).
int regexec (regex_t *compiled, char *string, size_t nmatch, regmatch_t matchptr [], int eflags) | Function |
This function tries to match the compiled regular expression
*compiled against string.
The argument eflags is a word of bit flags that enable various options. If you want to get information about what part of string actually
matched the regular expression or its subexpressions, use the arguments
matchptr and nmatch. Otherwise, pass |
You must match the regular expression with the same set of current locales that were in effect when you compiled the regular expression.
The function regexec
accepts the following flags in the
eflags argument:
REG_NOTBOL
REG_NOTEOL
Here are the possible nonzero values that regexec
can return:
REG_NOMATCH
REG_ESPACE
regexec
ran out of memory.