RegExMatch
Function RegExMatch( const ARegExpr, AInputStr : string) : boolean
Example
procedure ScriptEvent(var Value: variant);
begin
Value := RegExMatch('^[A-Z]{2}-[0-9]{4}$', 'NZ-2048'); // True
end;
Usage
RegExMatch reports whether a Velox regular expression finds any non-empty match within an input string.
Parameters
| Parameter | Meaning |
|---|---|
ARegExpr | Velox/PCRE regular-expression pattern. |
AInputStr | String searched by the pattern. |
Return value
True if TRegEx.IsMatch(AInputStr, ARegExpr) succeeds; otherwise False.
Important behavior and quirks
- Parameter order is pattern first, input second, although Velox's method receives input first.
- The default options are used. In the installed runtime these include
roNotEmpty, so a pattern does not report success solely for an empty match. - Matching is case-sensitive unless the expression supplies a supported inline case-insensitive option.
RegExMatch('cat', 'concatenate')isTrue; use^cat$when the entire input must match.- A Boolean
Falsemeans no qualifying match, not that the pattern was invalid.
Additional Technical Info
RegExMatch returns whether ARegExpr finds a non-empty match in AInputStr. The function searches anywhere in the input unless the pattern includes anchors such as ^ and $.
The example is fictional and source-reviewed only.
Errors, performance and concurrency
Invalid syntax raises a regular-expression exception rather than returning False. Each call constructs and prepares a new regex object. Expressions with catastrophic backtracking can consume disproportionate CPU; inputs and patterns from untrusted sources require external size, complexity or timeout controls. The per-call object is local and does not intentionally mutate Velox state.
External references
- Embarcadero DocWiki:
System.RegularExpressions.TRegEx.IsMatch - Free Pascal:
TRegExpr.Exec- analogous Boolean matching through a different engine/API.