3 * UCC (University [of WA] Computer Club) Electronic Accounting System
5 * doregex.c - Initialisation Code
7 * This file is licenced under the 3-clause BSD Licence. See the file
8 * COPYING for full details.
15 int RunRegex(regex_t *regex, const char *string, int nMatches, regmatch_t *matches, const char *errorMessage)
19 ret = regexec(regex, string, nMatches, matches, 0);
20 if( ret == REG_NOMATCH ) {
24 size_t len = regerror(ret, regex, NULL, 0);
26 regerror(ret, regex, errorStr, len);
27 printf("string = '%s'\n", string);
28 fprintf(stderr, "%s\n%s", errorMessage, errorStr);
35 void CompileRegex(regex_t *regex, const char *pattern, int flags)
37 int ret = regcomp(regex, pattern, flags);
39 size_t len = regerror(ret, regex, NULL, 0);
41 regerror(ret, regex, errorStr, len);
42 fprintf(stderr, "Regex compilation failed - %s\n%s\n", errorStr, pattern);