Regular expression engine written in ANSI C.
Features:
- Non-backtracking (linear-time execution guarantee)
- One
.h
file and one.c
file - Supports matching many distinct patterns at once (regexp sets)
- Syntax parity with re2
- ~6000 lines of code (only ~1800 semicolons)
- Extensively tested
- Pluggable allocator support
API | Syntax | Testing | Goals | Credits | TODO |
---|
#include <assert.h>
#include <string.h>
#include "bbre.h"
int main(void)
{
const char *text = "Hello WorLd!";
bbre *reg = bbre_init_pattern("Hel*o (?i)[w]orld!");
assert(bbre_is_match(reg, text, strlen(text)) == 1);
bbre_destroy(reg);
return 0;
}
I like regular expressions and C89.
That would have been too much fun.
"blueberry", because I ate a lot of frozen blueberries while I wrote this.
- Written in C89.
- Not optimized for memory fragmentation: uses lots of variable-size buffers.
- Assumes width of integer types in a way that's not completely compliant with C89/99. This works on 99% of platforms out there, but of course part of the fun in C is the esoteric 1%.
- Probably won't work on EBCDIC systems.