Difference between revisions of "Tip 15: GCC Regex Library"

From Vlsiwiki
Jump to: navigation, search
Line 15: Line 15:
 
  void  regfree(regex_t *);
 
  void  regfree(regex_t *);
  
Beyond that, read the man page [[http://pubs.opengroup.org/onlinepubs/007908799/xsh/regex.h.html]]
+
Beyond that, read the man page [http://pubs.opengroup.org/onlinepubs/007908799/xsh/regex.h.html[here]]

Revision as of 00:52, 9 March 2011

The C Regex library is standard with GCC and uses POSIX style regular expressions. This is opposed to Perl style regular expressions which are more common among scripting languages.

To include regex in C (or C++) you must include:

#include <sys/types.h>
#include <regex.h>

There are 4 available command:

int    regcomp(regex_t *, const char *, int);
int    regexec(const regex_t *, const char *, size_t, regmatch_t[], int);
size_t regerror(int, const regex_t *, char *, size_t);
void   regfree(regex_t *);

Beyond that, read the man page [here]