I have seen several Delphi examples of TRegEx
usage like the following one in Delphi 10.1.2:
try
RegexObj := TRegEx.Create(REGEX_EXTRACTEMAILADDRESSES, [roIgnoreCase]);
MatchResults := RegexObj.Match(ThisPageText);
while MatchResults.Success do
begin
slEmailAddressesOnThisPage.Add(MatchResults.Value);
MatchResults := MatchResults.NextMatch();
end;
except
on E: ERegularExpressionError do
begin
// Todo: Log Syntax error in the regular expression
end;
end;
So I wonder whether the TRegEx
object must be explicitly freed after creation in such an example?
constructor
keyword for them) is misleading, since there is no destructor. I would rather see them call those methods initializers and make them class functions returning a record of the given type. They should stop calling them constructors, as this question once again proves. – Adila