Last active
August 29, 2015 14:25
-
-
Save devpruthvi/04ca9406b395c277cada to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <regex.h> | |
#include<stdio.h> | |
int main(int arg, char * argv[]) | |
{ | |
regex_t regex; | |
int reti; | |
char msgbuf[100]; | |
reti = regcomp(®ex, "^[01]*1[01][01]$", 0); | |
if (reti) { | |
fprintf(stderr, "Could not compile regex\n"); | |
} | |
reti = regexec(®ex,argv[1], 0, NULL, 0); | |
if (!reti) { | |
puts("Match"); | |
} | |
else if (reti == REG_NOMATCH) { | |
puts("No match"); | |
} | |
else { | |
regerror(reti, ®ex, msgbuf, sizeof(msgbuf)); | |
fprintf(stderr, "Regex match failed: %s\n", msgbuf); | |
return 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment