tags:

views:

117

answers:

5

I'm thinking about writing a small application that will help me mass rename files. I currently use an application named 'RegexRenamer', which (I'm assuming) uses the .NET regex engine. The application is fine, but is sort of clunky.

So what I'm looking for is a C/C++ regex library that I can build my custom program off of. Anything that is small and lightweight is preferred (.Net seems heavy).

Thanks.

+7  A: 

boost regex supports named captures.

This chart in Wikipedia gives a comparison of several regex engines in a table of features vs library.

Brian R. Bondy
A: 
  • Perl Compatible Regular Expressions provided by the library PCRE
  • Oniguruma which is used by Ruby 1.9, PHP 5, and TextMate
Ken Bloom
A: 

Google's open sourced RE2 (PCRE compatible)

Stephen
RE2 doesn't support any sort of backreferences in its regular expressions, though it supports named capturing groups if all you care about is getting the data out for use in your program.
Ken Bloom
+1  A: 

Another free application, Bulk Rename Utility, already exist with this functionality as well.

Judge Maygarden
A: 

Barring some really good reason to choose something else, use the regular expression library in TR1 -- it's been adopted into C++0x almost unchanged, so when REs become a standard part of C++, using the standard one will be a simple matter of changing "std::tr1" to "std::" and re-compiling.

That was based on the Boost regex library, so if you start with them, the port should be pretty easy as well, though I believe Boost includes some features that weren't adopted into the standard.

Jerry Coffin
TR1 requires support for several different regex syntaxes, but none of those support named captures. (Boost's implementation supports Perl syntax as an *extension*, which does support named capturing groups.)
Ken Bloom