What's a portable and lightweight C/C++ regular expression library? [closed]
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this questionPossible Duplicate:
Lightweight and portable regex library for C/C++?
I'm looking for a C++ (C is acceptable, too) library for matching regular expressions. The library should satisfy these requirements:
- Can be built on Windows (MSVC 7 and newer)
- Can be built on Linux (g++ 3.4 and newer).
- Has no external dependencies; nothing but C/C++ runtime and STL allowed
- Works reasonably fast for small (~200 characters) strings to match against
I don't need a particular regexp flavor (POSIX, PCRE etc.) so anything is fine.
So far, I considered these libraries:
- re2: Interesting, but apparently no support for Windows builds
- PCRE doesn't seem terribly 'small' (over 1MB zipped sources) and doesn't seem to support Windows in its buildsystem.
- Boost Regex might fit the bill but I didn't spend开发者_JAVA技巧 much time on trying to figure out if I can build it standalone
Anything else maybe?
A quick Google for "pcre windows" seems to say that it does, in fact, support Windows. The .so
file on my system is < 200 KiB, so it doesn't seem to take up that much disk space either...
Try the GNU regex library.
http://www.gnu.org/s/libc/manual/html_node/Regular-Expressions.html
There's been at least one windows port:
http://people.delphiforums.com/gjc/gnu_regex.html
The C++ TR1 standard libraries contain regular expression classes. Newer versions of MSVC contain an implementation and there is Boost.Regex as a compiler independent implementation.
Mine! But you have to download it as part of another tool - csvfix. The regex code is in the alib library, is based on the code in Software Tools In Pascal, ported with a lot of changes to C++. It is very small, about 30K or less of source, supports ed-style rexexes, compiles on Windows and Linux, and I would love to get others to improve it.
Boost.Regex would fit your bill in terms of compilers, though it has dependencies on other parts of Boost.
精彩评论