TRE (computing)

TRE
Original author(s) Ville Laurikari
Written in C
Type Approximate string matching
License 2-clause BSD-like license
Website laurikari.net/tre/

TRE is an open-source library for pattern matching in text, which works like a regular expression engine with the ability to do approximate string matching. It is developed by Ville Laurikari and distributed under a 2-clause BSD-like license.

The library is written in C and provides functions which allow using regular expressions for searching over input text lines. The main difference from other regular expression engines is that TRE can match text fragments in an approximate way, that is, supposing that text could have some number of typos.

Features

TRE uses extended regular expression syntax with the addition of "directions" for matching preceding fragment in approximate way. Each of such directions specifies how many typos are allowed for this fragment.

Approximate matching is performed in a way similar to Levenshtein distance, which means that there are three types of typos 'recognized':[1]

TRE allows specifying of cost for each of three typos type independently.

The project comes with a command-line utility, a reimplementation of agrep.

Though approximate matching requires some syntax extension, when this feature is not used, TRE works like most of other regular expression matching engines. This means that

Predictable time and memory consumption

The library's author states[2] that time spent for matching grows linearly with increasing of input text length, while memory requirements are almost constant (tens of kilobytes).

Other

Other features, common for most regular expression engines could be checked in regex engines comparison tables or in list of TRE features on its web-page.

Usage example

Approximate matching directions are specified in curly brackets and should be distinguishable from repetitive quantifiers (possibly with inserting a space after opening bracket):

Language bindings

Apart from C, TRE is usable through bindings for Perl, Python and Haskell.[3] However if the project should be cross-platform, there would be necessary separate interface for each of the target platforms.

Disadvantages

Since other regular expression engines usually do not provide approximate matching ability, there is almost no concurrent implementation with which TRE could be compared. However there are few things which programmers may wish to be implemented in future releases:

See also

References

External links

This article is issued from Wikipedia - version of the Tuesday, February 16, 2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.