.*
pai Core Libraries
regex
Regular expression engine for PascalAI. Match patterns, search substrings, replace occurrences, find all matches, and extract capture groups.
Install ppm install regex
Usage Example
uses regex; var text := 'Hello, my email is alice@example.com'; // Check if pattern matches entire string if Match('^[A-Za-z ]+$', 'hello world') then WriteLn('Only letters'); // Search for pattern in string var pos := Search('[a-z]+@[a-z]+\.[a-z]+', text); WriteLn('Email found at: ' + IntToStr(pos)); // Replace all occurrences var clean := Replace('\d+', text, 'NUM'); // Find all matches var emails := FindAll('[a-z]+@[a-z]+\.[a-z]+', text); // Extract capture groups var grps := Groups('(\w+)@(\w+)', text);
Features
Full PCRE-compatible regular expression syntax
Match: check if pattern matches the full string
Search: find first occurrence position in string
Replace: substitute all matches with replacement string
FindAll: collect all non-overlapping matches
Groups: extract numbered capture groups from a match
← Back to Package Index