function GetNSubStringPos(N: Integer; SubString,AString: String): Integer;
//返回第n个SubString在AString中出现的位置
//如果没找到,返回-1
var
FindCount: Integer;
Pos: Integer;
begin
Result := -1;
Pos := 0;
for FindCount := 1 to N do begin
Inc(Pos);
while MidStr(AString, Pos, Length(SubString)) <> SubString do begin
if Length(AString) < Length(SubString) + Pos then
Exit;//未找到
Inc(Pos);
end;
end;
Result := Pos;
end;
//返回第n个SubString在AString中出现的位置
//如果没找到,返回-1
var
FindCount: Integer;
Pos: Integer;
begin
Result := -1;
Pos := 0;
for FindCount := 1 to N do begin
Inc(Pos);
while MidStr(AString, Pos, Length(SubString)) <> SubString do begin
if Length(AString) < Length(SubString) + Pos then
Exit;//未找到
Inc(Pos);
end;
end;
Result := Pos;
end;