title: c posix regex to validate input HH:MM:SS time string
body: <p>Related to <a href="https://stackoverflow.com/questions/8318236/regex-pattern-for-hhmmss-time-string">Regex pattern for HH:MM:SS time string</a>
  I am trying to validate user time input.</p>
  
  <pre><code>int main(int argc, char *argv[]){
          regex_t regex;
          int reti;
          char msgbuf[100];
          char inputStr2[100]="12:34:04";
          char inputStr[100]="12:34";
  
  /* Compile regular expression */
          reti = regcomp(&amp;regex, "^((([01]?[0-9]|2[0-3]):)?([0-5]?[0-9]):)?([0-5]?[0-9])$", 0);
          if( reti ){
          fprintf(stderr, "Could not compile regex\n");
          }
  
  /* Execute regular expression */
             printf("%s is the string\n",inputStr);
          reti = regexec(&amp;regex, inputStr, 0, NULL, 0);
          if( !reti ){
                  puts("Match");
          }
          else if( reti == REG_NOMATCH ){
                  puts("No match");
          }
          else{
                  regerror(reti, &amp;regex, msgbuf, sizeof(msgbuf));
                  fprintf(stderr, "Regex match failed: %s\n", msgbuf);
          }
           printf("%s is the string\n",inputStr2);
          reti = regexec(&amp;regex, inputStr2, 0, NULL, 0);
          if( !reti ){
                  puts("Match");
          }
          else if( reti == REG_NOMATCH ){
                  puts("No match");
          }
          else{
                  regerror(reti, &amp;regex, msgbuf, sizeof(msgbuf));
                  fprintf(stderr, "Regex match failed: %s\n", msgbuf);
          }
  /* Free compiled regular expression if you want to use the regex_t again */
      regfree(&amp;regex);
  
          return 0;
  }
  </code></pre>
  
  <ol>
  <li>i get the error unknown escape sequence '\d'.</li>
  </ol>
  
  <p>whats wrong here? Is this the best way to go about validating user time input?.
  Edit:
  Tried with <code>"^(?:(?:([01]?\\d|2[0-3]):)?([0-5]?\\d):)?([0-5]?\\d)$"</code> and i get a no match.
  Also with </p>