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
Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap lock dlopen | AC-Unsafe corrupt lock mem fd | See POSIX Safety Concepts.
This function tries to match the compiled regular expression
*compiled against string.
0if the regular expression matches; otherwise, it returns a nonzero value. See the table below for what nonzero values mean. You can use
regerrorto produce an error message string describing the reason for a nonzero value; see Regexp Cleanup.
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
0for nmatch, and
NULLfor matchptr. See Regexp Subexpressions.
You must match the regular expression with the same set of current locales that were in effect when you compiled the regular expression.
regexec accepts the following flags in the
Here are the possible nonzero values that
regexec can return:
regexecran out of memory.