我有一個問題,我不知道我怎麼可以提取HTML源代碼提取鏈接
HTML代碼多個環節都在Memo1和鏈接被提取到memo2 ..
我用這個函數來提取2個音符之間或2個弦之間的鏈接。
Function ExtractBetweenTags(Const Line, TagI, TagF: string): string;
var
i, f : integer;
begin
result := '';
i := Pos(TagI, Line);
f := Pos(TagF, Copy(Line, i+length(TagI), MAXINT));
if (i > 0) and (f > 0) then
Result:= Copy(Line, i+length(TagI), f-1);
end;
這讓只有1個鏈接.. 所以我怎樣才能得到我已經嘗試了很多次的所有鏈接,但沒有運氣:/
看Delphi的文檔'PosEx',它允許您設置下一個搜索起始位置。 –
使用一個html解析器http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 –
@大衛一般同意你,但你提供鏈接到具有巨大歷史的問題,很難找到有用的東西:)我把鏈接到一個庫我知道答案。 –