Easyregex: An easy way to match patterns with C

This is a little library I tossed together to make it relatively easy to use regular expressions in C. It uses the POSIX regular expression library, but allows you to avoid the horrific syntax. There are probably still bugs, if you find one, please shoot me an email and I'll try to fix them as soon as possible.

Turns this: (and I simplified the error handling in this example!)

regex_t preg;
size_t nmatch;
regmatch_t pmatch[2];
int result;

nmatch = 1;
result = regcomp(&preg, regular_expression, REG_EXTENDED);
if ( result != 0 )
if ( (result = regexec(&preg, buffer, nmatch, pmatch, 0)) != 0)
    if ( result != REG_NOMATCH )
strncpy(data, buffer + pmatch[1].rm_so, pmatch[1].rm_eo - pmatch[1].rm_so);
data[pmatch[1].rm_eo - pmatch[1].rm_so] = '\0';

Into this:

regex(buffer, regular_expression, REG_EXTENDED, 0, data);

There is a README and an INSTALL in the tarball with more information.

Current version: 1.0

Download the tarball.

Easyregex is distributed under the BSD license.

Webmaster: Jason Andresen

Last updated: April 6 2006