Excluir toda a instância de substring variável entre tags no Delphi
Eu estou extraindo texto legível do HTML em uma string e eu preciso remover o texto existente entre o<!--
e a-->
Tag. Qual seria a maneira mais eficiente de conseguir isso?
Agora eu estou fazendo assim:
function RemoveIEScripts(const s: string): string;
var
i: Integer;
InTag: Boolean;
begin
Result := '';
InTag := False;
for i := 1 to Length(s)-3 do
begin
if (s[i] = '<') and (s[i+1] = '!') and (s[i+2] = '-') then
inTag := True
else if (s[i] = '-') and (s[i+1] = '-') and (s[i+2] = '>') then
inTag := False
else if not InTag then
Result := Result + s[i];
end;
end;
Existe uma maneira melhor de fazer isso?