Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <pcre.h>
- int main () {
- pcre *re;
- const char *error;
- const char *subject ="test тест";
- int erroffset, rc;
- int ovector[30];
- re = pcre_compile(
- "^[А-Яа-я\\040]+$", /* the pattern */
- 0, /* default options */
- &error, /* for error message */
- &erroffset, /* for error offset */
- NULL ); /* use default character tables */
- if (re == NULL)
- {
- printf("PCRE compilation failed at offset %d: %s\n", erroffset, error);
- return 1;
- }
- rc = pcre_exec(
- re, /* the compiled pattern */
- NULL, /* no extra data - we didn't study the pattern */
- subject, /* the subject string */
- sizeof(*subject), /* the length of the subject */
- 0, /* start at offset 0 in the subject */
- 0, /* default options */
- ovector, /* output vector for substring information */
- 30);
- if (rc < 0) {
- switch(rc) {
- case PCRE_ERROR_NOMATCH: printf("No match\n"); break;
- case PCRE_ERROR_BADUTF8: printf("BAD UTF8!!!\n"); break;
- default: printf("Matching error %d\n", rc); break;
- }
- pcre_free(re);
- return 1;
- }
- printf("rc: %d\n",rc);
- pcre_free(re);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement