I'm trying to match words which doesn't have a letter 'd' in it , but the regexec is still matching the words with letter d
int main(void) {
regex_t regex;
char *str = "dabcd";
char *pattern = "[^d]*";
int ret;
ret = regcomp(®ex, pattern, 0);
if (ret == 0) {
printf("regex compilation successfully\n");
} else {
printf("regex compilation unsuccessful\n");
}
ret = regexec(®ex, str, 0, NULL, 0);
if (ret == 0) {
printf("there is a match\n");
} else {
printf("there is no match : %d\n", ret);
}
return 0;
}
how to solve it ? Is there something wrong with my regex expression?