简单的字符串处理,自己想一下算法就行了 这是我写的,可以参考下 //得到substr在SouseStr中第Index次出现的位置 function PosEx(subStr:string;SouseStr:string;Index:integer):integer; var i:integer; iPos:integer; AStr:string; begin AStr := SouseStr; result := 0; for i := 1 to Index do begin iPos := Pos(subStr,AStr); if iPos = 0 then exit; if i = Index then begin result := length(SouseStr) - length(AStr) + iPos; exit; end; System.Delete(AStr,1,iPos + length(subStr) - 1); end; end;
s:=InsertQry.fieldbyname('zhong').AsString; for i:=1 to length(s) do begin ss:=copy(s,pos(s[i],s)+1,255); if pos(s[i],ss) >0 then begin c:=c+1; k:=k+1; break; end; end;
Str:='http://www.xxx.com/dd.htm';如何返回:
http://www.xxx.com
这是我写的,可以参考下
//得到substr在SouseStr中第Index次出现的位置
function PosEx(subStr:string;SouseStr:string;Index:integer):integer;
var
i:integer;
iPos:integer;
AStr:string;
begin
AStr := SouseStr;
result := 0;
for i := 1 to Index do
begin
iPos := Pos(subStr,AStr);
if iPos = 0 then exit;
if i = Index then
begin
result := length(SouseStr) - length(AStr) + iPos;
exit;
end;
System.Delete(AStr,1,iPos + length(subStr) - 1);
end;
end;
for i:=1 to length(s) do begin
ss:=copy(s,pos(s[i],s)+1,255);
if pos(s[i],ss) >0 then begin
c:=c+1; k:=k+1;
break;
end;
end;