I'd like to use a Regex parser to aid in some string processing in a C application. I'm ideally looking for something lightweight and open-source. The target platform is an embedded system so we're looking to save as much as possible with memory consumption in particular. I've found a number of options online but was wondering if anyone can make additional suggestions that may help in this particular context.
Many thanks,
Scintilla, an open source text editor component, uses Ozan S. Yigit's RE engine
It was chosen because it is in the public domain (so no encumbering license) and very lightweight. But it is a bit limited... For what it is worth, RESearch.cxx uses a slightly more modern code (converted to C++ but it shouldn't be complex to convert it back to C) with some minor extensions made by myself (support of \d \s \w etc.).
There are some alternatives, like Henry Spencer's regular expression libraries.
Come to think of it, the Lua regex engine (in string library, gsub implementation among others) is probably fast and small too, like the language itself. It has its quirks and limitations, but it is very usable.
The side project LPeg can be an interesting alternative to REs, still lightweight yet powerful.
If you don't require a full featured regex implementation (and it sounds like you don't) then the code written by Brian Kernighan and Rob Pike highlighted in Beautiful Code will probably work for your needs. I found a Dr. Dobb's article which I think is the origination of the code which appears in the book.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With