Skip to content

Instantly share code, notes, and snippets.

@maxkleiner
Created January 11, 2021 20:01
Show Gist options
  • Save maxkleiner/86ffb832d10a7ee69d0d1a36f1d69a04 to your computer and use it in GitHub Desktop.
Save maxkleiner/86ffb832d10a7ee69d0d1a36f1d69a04 to your computer and use it in GitHub Desktop.
These e-mails were extracted with a RegEx as Regextractor
procedure RegEX_ExtractDemo;
var regEx: TRegExpr; //or OleVariant if HISUtils;
InStr, ResStr: String;
begin
ResStr:='';
InStr:= 'Please e-mail us at support@mycompany.com or to sales@mycompany.com';
// Create a regular expression
regEx:= TRegExpr.create; //HISUtils.RegExpr;
// Set regular expression pattern that specifies an e-mail address
regEx.Expression:='\w+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,6}';
// Execute search
if regEx.Exec(InStr) then Repeat
ResStr:= ResStr + regEx.Match[0] + '; ';
Until not regEx.ExecNext;
//Log.Message('These e-mails were extracted: '+ResStr);
writeln('These e-mails were extracted: '+ResStr);
// Posts the following to the log:
//'These e-mails were extracted: support@mycompany.com; sales@mycompany.com;'
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment