<div class="image"><a href="http://www.tumtx.com/xiaohuxing/wojiadeyangtai-10091191.html" title="我家的阳台" target="_blank"><img src="http://www.tumtx.com/pic/anhuxingfen/xiaohuxing/wojiadeyangtai-10091191-s.jpg" width="164" height="104" border="0" alt="我家的阳台 小户型,装修,图片"></a></div>
<a href="http://www.tumtx.com/xiaohuxing/wojiadeyangtai-10091191.html" title="我家的阳台" target="_blank">我家的阳台</a> <font color=#ffcc00>★</font><font color=#cccccc>☆</font><font color=#cccccc>☆</font><font color=#cccccc>☆</font><font color=#cccccc>☆</font><br/>
<div class="keyword">标签:<a href="http://www.tumtx.com/map/xiaohuxing" title="小户型" target="_blank">小户型</a> <a href="http://www.tumtx.com/map/zhuangxiu" title="装修" target="_blank">装修</a> <a href="http://www.tumtx.com/map/tupian" title="图片" target="_blank">图片</a> </div>
</div>
怎么把上面字符串中的网页截取出来成 如下 :
http://www.tumtx.com/xiaohuxing/wojiadeyangtai-10091191.html
http://www.tumtx.com/pic/anhuxingfen/xiaohuxing/wojiadeyangtai-10091191-s.jpg
http://www.tumtx.com/xiaohuxing/wojiadeyangtai-10091191.html
http://www.tumtx.com/map/xiaohuxing
http://www.tumtx.com/map/zhuangxiu
http://www.tumtx.com/map/tupian
var
i,j,k:Integer;
str1,str2:string;
html : string;
begin
Memo1.Text := html;
str2 := '';
j := 0;
k := 0;
j := Pos('href="',html);
Delete( html, 1, j );
用while 循环找后面应该怎么写呢?输出Memo2.Text
<a href="http://www.tumtx.com/xiaohuxing/wojiadeyangtai-10091191.html" title="我家的阳台" target="_blank">我家的阳台</a> <font color=#ffcc00>★</font><font color=#cccccc>☆</font><font color=#cccccc>☆</font><font color=#cccccc>☆</font><font color=#cccccc>☆</font><br/>
<div class="keyword">标签:<a href="http://www.tumtx.com/map/xiaohuxing" title="小户型" target="_blank">小户型</a> <a href="http://www.tumtx.com/map/zhuangxiu" title="装修" target="_blank">装修</a> <a href="http://www.tumtx.com/map/tupian" title="图片" target="_blank">图片</a> </div>
</div>
怎么把上面字符串中的网页截取出来成 如下 :
http://www.tumtx.com/xiaohuxing/wojiadeyangtai-10091191.html
http://www.tumtx.com/pic/anhuxingfen/xiaohuxing/wojiadeyangtai-10091191-s.jpg
http://www.tumtx.com/xiaohuxing/wojiadeyangtai-10091191.html
http://www.tumtx.com/map/xiaohuxing
http://www.tumtx.com/map/zhuangxiu
http://www.tumtx.com/map/tupian
var
i,j,k:Integer;
str1,str2:string;
html : string;
begin
Memo1.Text := html;
str2 := '';
j := 0;
k := 0;
j := Pos('href="',html);
Delete( html, 1, j );
用while 循环找后面应该怎么写呢?输出Memo2.Text
var
temp: String;
i: Integer;
begin
Result := TStringList.Create;
temp := Source;
i := pos(ch, Source);
while i <> 0 do
begin
Result.add(copy(temp, 0, i - 1));
Delete(temp, 1, i);
i := pos(ch, temp);
end;
Result.add(temp);
end;类似这样的方法
var
lstrlist1: TStringList;
I: Integer;
lstr: string;
begin
Memo2.Text := '';
lstrlist1 := TStringList.Create;
lstrlist1.DelimitedText := memo1.Text;
lstrlist1.Delimiter := '<';
for I := 0 to lstrlist1.Count - 1 do
if Pos('http',lstrlist1[i])>0 then
begin
lstr := Copy(lstrlist1[i],Pos('http',lstrlist1[i]),Length(lstrlist1[i]));
lstr := Copy(lstr,1,Pos(#34,lstr)-1);
Memo2.Text := Memo2.Text +#13+ lstr;
end;
lstrlist1.Free;
end;
#13 为回车
#34 为 ''
或使用posex
我也是在这里学的
实际上 常用的代码那就几句 只是换下正则表达式而以 没有相的那样复杂