Home

Awesome

FLRE - Fast Light Regular Expressions - A fast light regular expression library

FLRE ( F ast L ight R egular E xpressions) is a fast, safe and efficient regular expression library, which is implemented in Object Pascal (Delphi and Free Pascal) but which is even usable from other languages like C/C++ and so on. It requires PUCU.pas from PUCU for the Unicode data tables.

It implements the many of the most common Perl and POSIX features, except irregular expression features like forward references and nested back references and so on, which aren't supported at FLRE, only real "back" references are supported, hence also the word "Light" at the FLRE name. It also finds the leftmost-first match, the same match that Perl and PCRE would, and can return submatch information. But it also features a flag for a yet experimental POSIX-style leftmost-longest match behaviour mode.

FLRE is licensed under the LGPL v2.1 with static-linking-exception.

And as a side note, the experimental support for lookahead assertions and back references may be removed later again, if it is recognized later that these capabilities are not effective or not issue-free without backtracking, because FLRE is primarly a backtracking-free regular expression engine.

The secret of FLRE speed is that FLRE uses multiple subengines with automatic selection:

All these subengines are also UTF8 capable, where FLRE has Unicode 8.0.0 support, and where the UTF8 decoding work is baked into the regular expression DFA&NFA automations itself, so the underlying algorithms are still pure bytewise working algorithms, so that speed optimizations are easier to implement and where the code is overall less error-prone regarding bugs.

And as an addon, FLRE features prefix presearching. So for example the prefix for the example regex Hel(?:lo|loop) [A-Za-z]+ is Hello.

And FLRE can process 0-based null terminated C/C++ and 1-based (Object-)Pascal strings, so it has also a foreign API for usage with C/C++ (see FLRELib.dpr).

FLRE features a prefilter boolean expression string generation feature in two variants, once as simple variant and once as SQL variant. For example, FLRE converts (hello|hi) world[a-z]+and you into the prefilter boolean expression string ("hello world" OR "hi world") AND "and you" and into the prefilter boolean short expression string ("hello world"|"hi world")and you and into the prefilter SQL boolean full text search expression string +("hello world" "hi world") +("and you") and into the prefilter boolean SQL expression string (((field LIKE "%hello world%") OR (field like "%hi world%")) AND (field like "%and you%")) where the field name is freely choosable, and FLRE converts (hello|hi) world[a-z]+and you into the prefilter boolean expression string ("hello world" OR "hi world") AND * AND "and you" and into the prefilter boolean short expression string (hello world|hi world)*and you, so with wildcards then now. This feature can reduce the number of actual regular expression searches significantly, if you combine it with the data storage on the upper level (for example with with a text trigram index).

For a more complete engine with more features including backreferences and unicode support etc., see my old regular expression engine BRRE but otherwise FLRE is preferred now, since FLRE with its better structured code is more easily maintainable and therefore also overall less error-prone regarding bugs.

IRC: #flre on freenode

How-to-compile-the-code-examples youtube videos: https://youtu.be/rVdwOqo6rGQ and https://youtu.be/rVdwOqo6rGQ

Support me

Support me at Patreon