fork(2) download
  1. #include <stdio.h>
  2. #include <regex.h>
  3.  
  4. int main() {
  5. regex_t regex;
  6. int retis;
  7. char* str = "an:example";
  8.  
  9. retis = regcomp(&regex, "^[a-z]+:[a-z]+$", REG_EXTENDED);
  10. retis = regexec(&regex, str, 0, NULL, 0);
  11.  
  12. if(!retis) {
  13. puts("Match");
  14. }
  15. else if(retis == REG_NOMATCH) {
  16. puts("No match");
  17. }
  18.  
  19. regfree(&regex);
  20. return 0;
  21. }
Success #stdin #stdout 0s 5412KB
stdin
Standard input is empty
stdout
Match