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!)
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.rm_so, pmatch.rm_eo - pmatch.rm_so);
data[pmatch.rm_eo - pmatch.rm_so] = '\0';
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