Should free a TRegEx object after TRegEx.Create?

I saw several examples of Delphi usage TRegEx, for example, the following 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 if the explicit object TRegExshould be freed after being created in such an example?

+6
source share
1 answer

, TObject, . TRegEx record , , . TRegEx.Create - , , , , ( ).

+8

All Articles