A POSIX-compliant regex library with approximate (fuzzy) matching and predictable performance.
TRE is a POSIX-compliant regular expression library written in C, notable for its approximate (fuzzy) matching capabilities using edit-distance. It provides predictable, linear-time matching performance and includes the agrep command-line tool for fuzzy text search. The library solves problems where exact regex matches are too rigid, allowing for flexible pattern matching with controlled errors.
System programmers, tool developers, and researchers needing robust regex processing with fuzzy matching, especially in environments requiring POSIX compliance, thread safety, or binary data support.
Developers choose TRE for its unique combination of strict POSIX compliance, efficient fuzzy matching algorithm, and predictable performance without heavy memory overhead. Unlike many regex libraries, it offers built-in approximate matching with configurable costs and includes a production-ready agrep utility.
The approximate regex matching library and agrep command line tool.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
TRE uniquely supports approximate matching using Levenshtein distance, allowing configurable costs for insertions, deletions, and substitutions, which is rare in free regex libraries and included in the agrep tool.
The algorithm guarantees O(M²N) time complexity for most operations, ensuring consistent matching speed regardless of text length, with modest memory usage (less than 50K during compilation).
Adheres closely to IEEE Std 1003.1-2001, providing correct subpattern matching and standard behavior, which the README notes is uncommon even in non-free implementations.
Fully re-entrant APIs allow safe concurrent use across multiple threads, and it compiles on various platforms including Windows, FreeBSD, and macOS as listed in the README.
The README admits missing support for collating elements and equivalence classes due to portability issues, limiting full standards compliance compared to libraries like Regex++.
Perl-compatible features such as lookahead/lookbehind assertions are planned but not implemented, restricting regex expressiveness for developers needing modern syntax immediately.
Documentation for non-standard features like approximate matching is a work in progress, forcing users to rely on header files or source code, as noted in the README.
Requires autotools, automake, and other prerequisites for building, which can be cumbersome compared to simpler, header-only or package-managed libraries.