如何取出重复的字符?

cowbosky 2006-06-17 09:12:24

请问,在一个字符串中,如何将指定的第二个重复的值后面的字符取出?

比如:

Str:=http://adfarm.midiapaly.com/ck/dd.asp?mpro=http://pages.fox.com.cn/1yuan.html

如何返回:
http://pages.fox.com.cn/1yuan.html
...全文
141 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
bluemarry 2006-06-17
  • 打赏
  • 举报
回复
简单的字符串处理,自己想一下算法就行了
这是我写的,可以参考下
//得到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;
cowbosky 2006-06-17
  • 打赏
  • 举报
回复


还有如何取得一个网页的站点地址?

比如:
Str:='http://www.xxx.com/dd.htm';

如何返回:
http://www.xxx.com
cnhxjtoa 2006-06-17
  • 打赏
  • 举报
回复
ss就是重复后面的值,这只是其中的一个例子,自己想想办法吧
cnhxjtoa 2006-06-17
  • 打赏
  • 举报
回复
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;

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧