Skip to content

Instantly share code, notes, and snippets.

@thehydroimpulse
Created December 29, 2013 02:40
Show Gist options
  • Save thehydroimpulse/8166870 to your computer and use it in GitHub Desktop.
Save thehydroimpulse/8166870 to your computer and use it in GitHub Desktop.
rc = pcre_exec(
re, /* the compiled pattern */
NULL, /* no extra data - we didn't study the pattern */
subject, /* the subject string */
strlen(subject), /* the length of the subject */
0, /* start at offset 0 in the subject */
0, /* default options */
ovector, /* output vector for substring information */
OVECCOUNT); /* number of elements in the output vector */
if (rc < 0)
{
switch(rc)
{
case PCRE_ERROR_NOMATCH: printf("No match\n"); break;
/*
Handle other special cases if you like
*/
default: printf("Matching error %d\n", rc); break;
}
pcre_free(re); /* Release memory used for the compiled pattern */
return 1;
}
/* Match succeded */
printf("\nMatch succeeded at offset %d\n", ovector[0]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment