fork download
  1. #include "stdarg.h"
  2. #include "string.h"
  3. #include <ctype.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <regex.h>
  7.  
  8. int main()
  9. {
  10. char cmd[] = "WBRA|5|80|120|3|40|";
  11. int length = strlen(cmd);
  12. char check[100];
  13. int index = 0;
  14.  
  15. for(int i=4; i<length; i++){
  16. check[index++] = cmd[i];
  17. }
  18.  
  19. printf("%s\n", check);
  20. regex_t regex;
  21. int return_value;
  22. return_value = regcomp(&regex,"^\\|([0-9]+\\|)+$",REG_EXTENDED);
  23. return_value = regexec(&regex, check, 0, NULL, 0);
  24. printf("Result %d\n\r", return_value); // 0 is correct
  25. }
  26.  
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
|5|80|120|3|40|
Result 0