mpreg - minimal parser for regular expressions
a c99 header-only library for parsing (limited) regular expressions
in order of precedence:
- a non-reserved character is a regex
- if
ais a regex,a*is a regex representing the kleene closure ofa - if
ais a regex,a+is a regex representing the kleene star closure ofa - if
aandbare regexes,a.brepresents the concatenation ofaandb - if
aandbare regexes,a|brepresents the union ofaandb
mpreg exports one struct mpreg_t and three functions
/* used to compile a pattern into a regular expression. returns true if successful, false if pattern is invalid. */
bool mpreg_compile(mpreg_t*, char*);
/* used to match a string against a compiled regular expression. returns true on match, false if otherwise. */
bool mpreg_match(mpreg_t*, char*);
/* used to deallocate memory used by a compiled regex. regex cannot be used after this. */
void mpreg_free(mpreg_t*);