I have the following regex:
^(?!avoid).*
I have checket that it works, using https://regex101.com/:
However, if I try to compile it using regcomp in a C program like this:
#include <regex.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
regex_t preg;
char *pattern = "^(?!avoid).*";
int rc;
char buffer[100];
if (0 != (rc = regcomp(&preg, pattern, REG_EXTENDED))) {
regerror(rc, &preg, buffer, 100);
printf("regcomp() failed with '%s'\n", buffer);
exit(-1);
}
return 0;
}
I get the following error:
regcomp() failed with 'Invalid preceding regular expression'
What am I doing wrong? :)