int main(void) {
char* mystring = "This is a foo line.";
char* pattern = "foo";
mystring,
pattern,
"replaced"
);
if (!replaced) return EXIT_FAILURE;
printf("%s\n", replaced);
free(replaced);
mystring,
pattern,
);
if (!replaced) return EXIT_FAILURE;
printf("%s\n", replaced);
free(replaced);
mystring,
pattern,
" ",
)
);
if (!replaced) return EXIT_FAILURE;
printf("%s\n", replaced);
free(replaced);
char* mytemplate =
"This is REDuseful?" NC;
mytemplate,
"RED",
);
if (!replaced) return EXIT_FAILURE;
printf("%s\n", replaced);
free(replaced);
char* mypatstring = "I think this is a beautiful thing.";
regex_t mypat;
if (regcomp(&mypat, "th[a-z]+", REG_EXTENDED)) {
regfree(&mypat);
fprintf(stderr, "Failed to compile regex!\n");
return EXIT_FAILURE;
}
regfree(&mypat);
if (!replaced) return EXIT_FAILURE;
puts(replaced);
free(replaced);
return EXIT_SUCCESS;
}