Some regular expression libraries
While I’m on the lookout for small libraries anyway, I thought I’d also post a list of a few regular expression libraries I’ve found recently (again, for possible use in an embedded Linux system).
So if you need a small or medium sized regex library for one of your projects, here’s a start:
- SLRE (Super Light Regular Expression library): 15KB of C, but still a decent subset of Perl regexes. Simple API, doesn’t use heap.
- T-Rex: Again, very light at 17KB of C, but good subset of Perl regexes. Uses heap, has a C++ wrapper class.
- TRE: C, lightweight but powerful and POSIX-compliant, looks very good.
- PCRE, C (with C++ wrapper), heavyish, fully-fledged, Unicode support, industry-standard (used in Apache etc).
- Boost.Xpressive: C++ header only, heavyish, API okay, quite hard to extract from Boost.
- Boost.Regex: C++, heavyish, API looks good, hard to extract from Boost.
Being a bloat despiser myself, I love the idea of using just 15KB of source code to handle your regexen. If you need something more powerful, however, TRE does look very good. Somehow reminds me of TCC (Tiny C Compiler).
27 February 2009 by Ben 5 comments
5 comments (oldest first)
Thank you for the link to SLRE. I just dropped the header file and single c file into my src directory and it compiled with no problems, I didn’t even have to change my Makefile.
I am trying to convert my website to use ‘c’ cgi and want to use regular expressions but found that other regexp libraries more than doubled the final executable size!
I used T-Rex, it has some nasty bugs, dropped it.
Nice list – it was very helpful! You might want to add GRETA as well.
T-Rex can’t solve regexp like a?a correctly. Its ‘invalid range’ is wrong, too.
Good post….thanks for sharing.. very useful for me, I will
bookmark this for my future needs.