例子:
var
AFile: TStrings;
S: string;
const
title = '<title>.*?</title>';
begin
AFile := TStringList.Create;
AFile.LoadFromFile('F:\Content.txt');
with TRegExpr.Create do
try
Expression := title;
if Exec(AFile.Text) then
begin
S := Match[0];
S := Copy(S, 8, Length(S)-7-8);
ShowMessage(S);
end;
finally
AFile.Free;
Free;
end;
end;
var
AFile: TStrings;
S: string;
const
title = '<title>.*?</title>';
begin
AFile := TStringList.Create;
AFile.LoadFromFile('F:\Content.txt');
with TRegExpr.Create do
try
Expression := title;
if Exec(AFile.Text) then
begin
S := Match[0];
S := Copy(S, 8, Length(S)-7-8);
ShowMessage(S);
end;
finally
AFile.Free;
Free;
end;
end;
其他的怎么写,首先要了解正则表达式的语法,然后结合原始数据决定