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.
10 /* Must be included */
13 int main(int argc,char **argv)
18 /* OSRegex structure */
21 /* checking for arguments */
24 printf("%s regex string\n",argv[0]);
29 /* If the compilation failed, we don't need to free anything.
30 * We are passing the OS_RETURN_SUBSTRING because we wan't the
33 if(OSRegex_Compile(argv[1], ®, OS_RETURN_SUBSTRING))
36 /* If the execution succeeds, the substrings will be
39 if((retv = OSRegex_Execute(argv[2], ®)))
45 printf("next pt: '%s'\n", retv);
46 /* Assigning reg.sub_strings to ret */
47 ret = reg.sub_strings;
49 printf("substrings:\n");
52 printf(" %d: !%s!\n", sub_size, *ret);
56 /* We must free the substrings */
57 OSRegex_FreeSubStrings(®);
61 printf("Error: Didn't match.\n");
64 OSRegex_FreePattern(®);
67 /* Compilation error */
70 printf("Error: Regex Compile Error: %d\n", reg.error);