regex.c (285B)
1 #include <stdlib.h> 2 #include <regex.h> 3 #include <stdio.h> 4 5 void eprint(char *msg){ 6 fprintf(stderr, "%s\n", msg); 7 exit(1); 8 } 9 10 int main(){ 11 regex_t expr; 12 if (regcomp(&expr, "(1|0)+", 0) != 0) eprint("regcomp failed!"); 13 int ret = regexec(&expr, "1010", 0, NULL, 0); 14 printf("%d\n", ret); 15 }