Created
October 26, 2012 15:16
-
-
Save BenBergman/3959357 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
// String I want to match: "SWI9600M_01\\.00\\.09\\.03AP R2492 CARMD-EN-10526 2011/07/01 19:31:09\n" | |
int validate_string_with_regex(const char *string, const char *regex_str) { | |
regex_t regex; | |
/* Compile regular expression */ | |
int reti = regcomp(®ex, regex_str, REG_EXTENDED); | |
if (reti != 0) { | |
fprintf(stderr, "Could not compile regex\n"); | |
return reti; | |
} | |
/* Execute regular expression */ | |
reti = regexec(®ex, string, 0, NULL, 0); | |
return reti; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment