I'm looking for a robust, easy-to-use, regular expression evaluator for native C++, either platform-independent or Windows-specific.
Requirements:
- Can't use Boost or ACE regex libraries (unfortunately)
- Can't use .NET Regex (or any managed code)
The main requirement is that it should be standalone and open.
C++11 now includes the support of regular expressions. It will be platform independent. You just need a recent compiler. Check the following list to know which one to use.
http://wiki.apache.org/stdcxx/C%2B%2B0xCompilerSupport
Hope it helps
try libpcre
If you're stuck on windows they have a windows port which should work. I know e-texteditor uses it, so at least that's proof it works :-)
If you use Visual Studio you can use Visual C++ 2008 Feature Pack Release, this implements some of TR1, and includes regular expression parsing. Get it
Qt has also a nice Regular Expression implementation QRegExp. It is also platform independent.
The GNU C Library supports regular expressions. It's open, and the RE code seems to be easily extractable.
The GNU C library regular expressions facility (regcomp(), regexec() and friends) is broken. Use libetre instead; the function signatures match the ones provided by glibc. http://laurikari.net/tre/
I would second the recommendation for PCRE. I have used it in C++ projects in Windows and it works great. It's free, even for building commercial software. It also implements something of a de facto standard regular expression language, which will be welcome to your users. PCRE is of course Perl-compatible, and Python also uses the same library.
The native PCRE interface is a bit awkward and very C-style, so it's probably worth writing a nice C++ wrapper around it. There is very likely already is one out there, but I'm not familiar with any.
C++11 and forward now contains the standard regular expression library.
Include the
<regex>
header, and use.Why don't you use Microsoft ATL's regex library? Kenny Kerr has written a short article on that recently.
The free ATL Server Library and Tools from CodePlex includes a regex parser. See AtlServer in the CodePlex Archive