RegEx.FindMatches |
Top Previous Next |
Finds text using regular expressions.
Syntax function RegEx.FindMatches(Pattern: string; Subject: string; [Matches: array]): boolean
Alternative Names
Description Attempts to match text using regular expressions and optionally returned a list of matches items.
The Pattern is the regular expression that will be used to match text in the Subject.
If a third input Matches has been supplied, this is the array where resulting found matches will be listed.
The Return Value is TRUE when matches have been found, FALSE otherwise.
See also
Example execute udsblock as begin Subject = 'test m@nu.nl and then some z@example.com and more, @, test. finally fake@web.com'; EMailMatch = '[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+';
MyResults = null; /* Array.Create(''); */
/* attempt to match e-mail addresses in the given text */ RegEx.FindMatches(EMailMatch, Subject, MyResults);
/* display the number of items found */ GUI.ShowMessage('Items found: ' || Array.Length(MyResults)); /* cycle the resulting array and show each entry */ foreach (MyResults as foundval) do begin GUI.Showmessage('Following e-mail addres found: ' || foundval); end;
/* now, replace the e-mail addresses in the Subject with nospam@example.com */ NewSubject = RegEx.ReplaceMatches(EMailMatch, 'nospam@example.com', Subject);
GUI.ShowMessage('Modified text: ' || NewSubject); end; |