- Introduction
- License
- History
- Compilation & Hosting
- Configuration File
- Modules:
- FAQ
- Links
- Credits
|
PSP - RegExp Unit Reference
Procedures and Functions:
Examples:
- PSP_ROOT/src/examples/regtest.pp
Introduction
Regular expressions are pretty comfortable way of parsing string data. It is some kind of "text description language", describing text masks and performing matches. You can use them when you need a quick way to check if string matches a pattern, if you need to extract some parts of the string or if you want to replace some parts of it.
Before learning about functions of this unit you should read about regular expressions syntax. There is original TRegExpr syntax manual here and then some notes about regular expressions in PSP.
Types
RegexpEntry = Pointer;
// RegExp entry struct pointer
RegexpResult = Pointer;
// Global match result pointer
StrArray = array of string;
Tips and Tricks
- Regular expressions are very universal but very slow. For special tasks such as HTML parsing use manual string parsing algorithms and/or substrings.
- Try to avoid parsing long strings. The longer input data is the slower regexp works.
|