1 /* Copyright by Daniel B. Cid (2005, 2006)
2 * Under the public domain. It is just an example.
3 * Some examples of usage for the os_regex library.
13 int main(int argc, char **argv)
17 /* OSRegex structure */
20 /* Check for arguments */
22 printf("%s regex string\n", argv[0]);
26 /* If the compilation failed, we don't need to free anything.
27 * We are passing the OS_RETURN_SUBSTRING because we want the
30 if (OSRegex_Compile(argv[1], ®, OS_RETURN_SUBSTRING)) {
32 /* If the execution succeeds, the substrings will be
35 if ((retv = OSRegex_Execute(argv[2], ®))) {
41 printf("next pt: '%s'\n", retv);
42 /* Assign reg.sub_strings to ret */
43 ret = reg.sub_strings;
45 printf("substrings:\n");
47 printf(" %d: !%s!\n", sub_size, *ret);
52 /* We must free the substrings */
53 OSRegex_FreeSubStrings(®);
55 printf("Error: Didn't match.\n");
58 OSRegex_FreePattern(®);
61 /* Compilation error */
63 printf("Error: Regex Compile Error: %d\n", reg.error);