#include <stdio.h>
#include <string.h>
#include <regex.h>
int match(const char *string, const char *pattern) {
regex_t regex;
int result;
regcomp(®ex, pattern, 0);
result = regexec(®ex, string, 0, NULL, 0);
regfree(®ex);
return result == 0;
}
int main() {
printf("%d\n", match("bud", "b.d"));
printf("%d\n", match("bid", "b.d"));
printf("%d\n", match("bed", "b.d"));
printf("%d\n", match("b d", "b.d"));
printf("%d\n", match("bat", "b.d"));
printf("%d\n", match("bd", "b.d"));
printf("%d\n", match("bead", "b.d"));
return 0;
}
/*
run:
1
1
1
1
0
0
0
*/