title: C POSIX ERE without back-references
body: <p>I need to include in my C code a POSIX ERE regex compiler/executer. I settled on the native regex.h library with something that looks like the following:</p>
  
  <pre><code>#include &lt;regex.h&gt;
  
  bool
  match_posix_regex(const char *pattern, const char *str){
      regex_t regex;
      int reti;
  
      reti = regcomp(&amp;regex, pattern, REG_EXTENDED);
      if(reti){
          printf("Could not compile the regex\n");
          return false;
      }
  
      reti = regexec(&amp;regex, str, 0, NULL, 0);
      if(!reti){
          return true;
      }
  
      else if (reti == REG_NOMATCH){
          return false;
      }
  
      else{
          printf("ERROR in regex execution\n");
          return false;
      }
  }
  </code></pre>
  
  <p>It came to my attention that this implementation includes support for back-referencing. It is my understanding that POSIX ERE standards do <a href="https://stackoverflow.com/questions/13322996/do-extended-regexes-support-back-references">not support</a> back-referencing, however many implementations of these standards do. Looking at the regex.h <a href="http://pubs.opengroup.org/onlinepubs/7908799/xsh/regex.h.html" rel="nofollow noreferrer">docs</a> it doesn't seem like I'll be able to disable this feature.</p>
  
  <p>I do not want to include support for back-referencing as it is not included in the standards and furthermore it can result in catastrophic backtracking as described <a href="https://stackoverflow.com/questions/11101405/how-do-backreferences-in-regexes-make-backtracking-required">here</a>. </p>
  
  <p>Is there a way I can compile and run a regex in C that is compliant with POSIX ERE standards and does <em>not</em> include back-referencing as a feature?  </p>