int main(void) {
char* mystring = "This was foo. I mean foo.";
char* pattern = "foo";
mystring,
pattern,
"replacement"
);
if (!replaced) return EXIT_FAILURE;
puts(replaced);
free(replaced);
mystring,
pattern,
);
if (!replaced) return EXIT_FAILURE;
puts(replaced);
free(replaced);
mystring,
pattern,
" ",
)
);
if (!replaced) return EXIT_FAILURE;
puts(replaced);
free(replaced);
char* mytemplate =
"This REDis " NC "kinda REDuseful" NC "?";
mytemplate,
"RED",
);
if (!replaced) return EXIT_FAILURE;
puts(replaced);
free(replaced);
char* mymatchstring = "I think this is a beautiful thing.";
regex_t pat;
if (regcomp(&pat, "th[a-z]+", REG_EXTENDED)) {
regfree(&pat);
fprintf(stderr, "Failed to compile regex!\n");
return EXIT_FAILURE;
}
regfree(&pat);
if (!matches) {
fprintf(stderr, "Failed to match anything!\n");
return EXIT_FAILURE;
}
if (!replaced) return EXIT_FAILURE;
puts(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;
}