Pattern String Engine (PSE) is a freeware library for work with regular expressions in Borland Delphi/Kylxi. As distinct from the other libaries, the regular expressions are described by special pattern collection and not by symbol line. The library contains the great number of intrinsiced patterns and allows to easy create the new patterns for specific applications.
PSE allows not just checking the line to similarity with regular expression, but also getting all possible ways of similarity the line to the pattern. Some parts of line can be extracted from to variable for the next processing.
The base abstract class in Pattern String Engine is TPattern.
The various particularized patterns are generated from it:
The main idea is regular expressions may be represented as simple patterns tree. For example, identifier pattern in programming language - letters and numbers order started with letter:
describes in PSE in such way:
PSE, PSEChar and PSECharSet - are the functions that create object-pattern of conformable tipes.
The example of more complicated pattern that processes dates at various sizes:
This pattern identifies the differnt month spelling (by numbers
and abbriviation), looks after separators to be similar.
Having a created pattern we can check out the similarity of any line to this pattern.For example, the next code checks out the similarity SourceString line to the pattern <number> [+ -* /] <number>
Usually it is necessary to define the compliance of line to the pattern, and to divide the line into some elemts. It` s very easy to do using PSE:
In comparison process, the resalts will be saved to variables num1, num2 and sign.