<meta name="keywords" content="这是内容"/>
<META name="keywords" content="这是内容"/>
<meta name="Keywords" content="这是内容"/>
<meta content="这是内容" name="keywords"/>
<meta content='这是内容' name='keywords'/>
<meta content='这是内容' name='keywords' >
最后得到结果:
这是内容
应考虑到适应网络上各种页面的需要,如大小写,name与content次序不同,标签最后以>而不是/>闭合等,应适应delphi里的TRegExp(或其它)的写法
<META name="keywords" content="这是内容"/>
<meta name="Keywords" content="这是内容"/>
<meta content="这是内容" name="keywords"/>
<meta content='这是内容' name='keywords'/>
<meta content='这是内容' name='keywords' >
最后得到结果:
这是内容
应考虑到适应网络上各种页面的需要,如大小写,name与content次序不同,标签最后以>而不是/>闭合等,应适应delphi里的TRegExp(或其它)的写法
最常用的函数就是:getTag
getByTag(sHtml,'content="','" ')得到内容
getByTag(sHtml,'name="','" ')得到key
当然,还需要移动、判断sHtml的当前位置
begin
GegValues(Memo1.Text);
end;procedure TForm1.GegValues(s: string);
var
reg:TRegExpr;
begin
reg := TRegExpr.Create;
reg.Expression := '(<meta|<META)(.*?)(name="|name='+#39+')(.*?)("|'+#39+')';
if reg.Exec(s) then
begin
repeat
ListBox1.Items.Add(reg.Match[4]);
until not reg.ExecNext;
end;
reg.Free;
end;