Diff
checker
文本
文本
圖像
文檔
Excel
文件夾
Legal
Enterprise
桌面版
定價
登入
下載 Diffchecker 桌面版
比較文本
尋找兩個文字檔案之間的差異
工具
歷史
即時編輯器
摺疊未變更行
關閉換行
檢視
拆分
統一
比對精度
智能
單詞
字符
語法突出顯示
選擇語法
忽略
文字轉換
前往第一個差異
編輯輸入
Diffchecker Desktop
執行Diffchecker最安全的方式。取得Diffchecker桌面應用程式:您的差異永遠不會離開您的電腦!
取得桌面版
Untitled diff
建立於
9 年前
差異永不過期
清除
匯出
分享
解釋
30 刪除
行
總計
刪除
字符
總計
刪除
要繼續使用此功能,請升級到
Diff
checker
Pro
查看價格
39 行
全部複製
45 新增
行
總計
新增
字符
總計
新增
要繼續使用此功能,請升級到
Diff
checker
Pro
查看價格
50 行
全部複製
function TTextTestImporter.ParseHeader(Lines: TStrings): Boolean;
function TTextTestImporter.ParseHeader(Lines: TStrings): Boolean;
var
var
複製
已複製
複製
已複製
i, Pos1, Pos2, Pos3, Pos4, Age: Integer
;
PatientFound, DateFound: Boolean
;
Line, PatientName
: String;
Line, PatientName
, AgeStr, BirthDateStr, DateStr
: String;
PatientRegex, DateRegex: TRegExpr;
i: Integer;
begin
begin
複製
已複製
複製
已複製
PatientRegex := TRegExpr.Create;
PatientRegex.Expression := 'Paciente\s+:*(.*)\s{2,}Idade:+(\d+)\s*anos\s*Nascimento:*(.+)';
PatientRegex.ModifierI := True;
PatientRegex.ModifierG := True;
DateRegex := TRegExpr.Create;
DateRegex.Expression := 'Data\s*de\s*Cadastro\.*\s*:*(.+)';
DateRegex.ModifierI := True;
DateRegex.ModifierG := True;
Result := False;
Result := False;
複製
已複製
複製
已複製
for i := 0 to Lines.Count -
1 do
PatientFound := False;
DateFound := False;
for i := 0 to Lines.Count -
1 do
begin
begin
複製
已複製
複製
已複製
if
Result
then
if
(DateFound and PatientFound) or (i > 20)
then
Exit
;
break
;
Line :=
UpperCase(
Trim(Lines[i])
)
;
Line :=
Trim(Lines[i])
;
if
AnsiStartsStr('PACIENTE',
Line) then
if
not PatientFound and PatientRegex.Exec(
Line) then
begin
begin
複製
已複製
複製
已複製
Pos1 := PosEx(':', Line, Length('PACIENTE') + 1);
PatientFound := True;
if Pos1 > 0 then
PatientName := Trim(PatientRegex.Match[1]);
begin
AgeStr := Trim(
Patient
Regex.Match[2]);
Pos2 := RPos('IDADE', Line);
BirthDateStr
:=
Trim(PatientRegex.Match[3]);
if Pos2 > 0 then
FData.Strings['name'] := PatientName;
begin
FData.Integers['age'] :=
StrToIntDef(
Age
Str, 0)
;
PatientName := Trim(Copy(Line, Pos1 + 1, Pos2 - Pos1 - 1));
FData.Floats['birthdate'] := ScanDateTime('dd/mm/yy', BirthDateStr)
;
if
Patient
Name <> '' then
continue;
begin
end;
Result
:=
True;
FData.Strings['name'] := PatientName;
if not DateFound and DateRegex.Exec(Line) then
Pos3 := PosEx(':', Line, Pos2);
begin
if Pos3 <> 0 then
DateFound := True;
begin
DateStr := Trim(DateRegex.Match[1]);
Pos4 := PosEx('ANOS', Line, Pos3);
FData.Floats['date'] := ScanDateTime('dd/mm/yyyy', DateStr)
;
if TryStrToInt(Trim(Copy(Line, Pos3 + 1, Pos4 - Pos3 - 1)), Age) then
FData.Integers['age'] :=
Age
;
end
;
end;
end;
end
;
end;
end;
end;
end;
複製
已複製
複製
已複製
Result := DateFound and PatientFound
and (FData.Get('name', '') <> '')
and (FData.Get('age', 0) <> 0)
and (FData.Get('birthdate', 0.0) <> 0)
and (FData.Get('date', 0.0) <> 0);
end;
end;
複製
已複製
複製
已複製
已保存差異
原始文本
開啟檔案
function TTextTestImporter.ParseHeader(Lines: TStrings): Boolean; var i, Pos1, Pos2, Pos3, Pos4, Age: Integer; Line, PatientName: String; begin Result := False; for i := 0 to Lines.Count -1 do begin if Result then Exit; Line := UpperCase(Trim(Lines[i])); if AnsiStartsStr('PACIENTE', Line) then begin Pos1 := PosEx(':', Line, Length('PACIENTE') + 1); if Pos1 > 0 then begin Pos2 := RPos('IDADE', Line); if Pos2 > 0 then begin PatientName := Trim(Copy(Line, Pos1 + 1, Pos2 - Pos1 - 1)); if PatientName <> '' then begin Result := True; FData.Strings['name'] := PatientName; Pos3 := PosEx(':', Line, Pos2); if Pos3 <> 0 then begin Pos4 := PosEx('ANOS', Line, Pos3); if TryStrToInt(Trim(Copy(Line, Pos3 + 1, Pos4 - Pos3 - 1)), Age) then FData.Integers['age'] := Age; end; end; end; end; end; end; end;
更改後文本
開啟檔案
function TTextTestImporter.ParseHeader(Lines: TStrings): Boolean; var PatientFound, DateFound: Boolean; Line, PatientName, AgeStr, BirthDateStr, DateStr: String; PatientRegex, DateRegex: TRegExpr; i: Integer; begin PatientRegex := TRegExpr.Create; PatientRegex.Expression := 'Paciente\s+:*(.*)\s{2,}Idade:+(\d+)\s*anos\s*Nascimento:*(.+)'; PatientRegex.ModifierI := True; PatientRegex.ModifierG := True; DateRegex := TRegExpr.Create; DateRegex.Expression := 'Data\s*de\s*Cadastro\.*\s*:*(.+)'; DateRegex.ModifierI := True; DateRegex.ModifierG := True; Result := False; PatientFound := False; DateFound := False; for i := 0 to Lines.Count - 1 do begin if (DateFound and PatientFound) or (i > 20) then break; Line := Trim(Lines[i]); if not PatientFound and PatientRegex.Exec(Line) then begin PatientFound := True; PatientName := Trim(PatientRegex.Match[1]); AgeStr := Trim(PatientRegex.Match[2]); BirthDateStr := Trim(PatientRegex.Match[3]); FData.Strings['name'] := PatientName; FData.Integers['age'] := StrToIntDef(AgeStr, 0); FData.Floats['birthdate'] := ScanDateTime('dd/mm/yy', BirthDateStr); continue; end; if not DateFound and DateRegex.Exec(Line) then begin DateFound := True; DateStr := Trim(DateRegex.Match[1]); FData.Floats['date'] := ScanDateTime('dd/mm/yyyy', DateStr); end; end; Result := DateFound and PatientFound and (FData.Get('name', '') <> '') and (FData.Get('age', 0) <> 0) and (FData.Get('birthdate', 0.0) <> 0) and (FData.Get('date', 0.0) <> 0); end;
尋找差異