Professional Documents
Culture Documents
The pattern is a standard glob expression with four special characters , modified
by the flags argument:
1. * Matches any string, including an empty one.
characters not to match. The whole list matches, or does not match, a single
character. The list is terminated by a ] .
4. \ Causes the next character to be interpreted literally instead of as a special
character.
Flags
FNM_NOESCAPE Treat \ as an ordinary
character, not a special character.
FNM_PATHNAME Do not match / characters in
string with a *, ? , or even a [/] sequence in pattern;
match it only with a literal, nonspecial / .
FNM_PERIOD A leading character in pattern
matches a . character in string only if it is the first
character in string
Regular expressions
Regular expressions have two flavors:
basic regular expressions (BREs) grep
extended regular expressions (EREs) egrep.
Regular expression matching
#include <regex.h>
• 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);
• void regfree(regex_t *preg);
• size_t regerror(int errcode, const regex_t *preg,
char *errbuf, size_t errbuf_size);
Before comparing a string to a regular expression, you
need to compile it with the regcomp() function.
The regex_t *preg holds all the state for the regular
expression.
typedef struct {
} regmatch_t;