各位大侠好,DELPHI中正则一直用的不太熟悉,希望大家帮下忙
1:自定义正则提取方式INI文件
[Rule]
Url=http://www.haozs.net/proxyip/
Rule=<td>$ip$</td><td>anonymous</td><td>$area$</td>2:我希望能通过正则提取URL中的内容,需要提取的东西为$ip$和$area$
Rule里的东西是对照URL内容里得到的.如何按照上面的定义提取呢?提取结果我想保存到一个数组里.另外我是引用VBSCRIPT里的VBScript_RegExp_55_TLB
1:自定义正则提取方式INI文件
[Rule]
Url=http://www.haozs.net/proxyip/
Rule=<td>$ip$</td><td>anonymous</td><td>$area$</td>2:我希望能通过正则提取URL中的内容,需要提取的东西为$ip$和$area$
Rule里的东西是对照URL内容里得到的.如何按照上面的定义提取呢?提取结果我想保存到一个数组里.另外我是引用VBSCRIPT里的VBScript_RegExp_55_TLB
sip:=gettag(s,'<td>','</td> <td>anonymous');
sarea:=gettag(s,'anonymous </td> <td>','</td>');
string strSrc = "页中的 <a href=\ "http://www.baidu.com\ " class = ...> 百 度 </a> ";
string strRegex = "(? <url> (? <= <a href ?= ?\ "?)[^\ "> ]+?(?=\ "|> )).*(? <Text> (? <=> )[^ <]+?(?= </a> )) ";
Match res = Regex.Match(strSrc, strRegex);
if (res.Success)
{
MessageBox.Show(res.Groups[ "url "].Value);
MessageBox.Show(res.Groups[ "Text "].Value);
}这个在DELPHI中不知道如何转换
二楼,你这样只能提取一个,我是要提取多个的,,
感谢你们.继续期待
类似
[Rule]
Url=http://www.haozs.net/proxyip/
Rule= <td>$ip$ </td> <td>anonymous </td> <td>$area$ </td>
[Rule]
Url=http://www.haozs.net/proxyip/
tagcount=2
tag1h=<td>
tag1t=</td> <td>anonymous </td> <td>$area$ </td>
tag2h=anonymous </td> <td>
tag1t= </td>
Url=http://www.haozs.net/proxyip/
tagcount=2
tag1h= <td>
tag1t= </td> <td>anonymous </td> <td>$area$ </td>
tag2h=anonymous </td> <td>
tag2t= </td>
还不是想要的答案...
string strSrc = "页中的 <a href=\ "http://www.baidu.com\ " class = ...> 百 度 </a> ";
string strRegex = "(? <url> (? <= <a href ?= ?\ "?)[^\ "> ]+?(?=\ "|> )).*(? <Text> (? <=> )[^ <]+?(?= </a> )) ";
Match res = Regex.Match(strSrc, strRegex);
if (res.Success)
{
MessageBox.Show(res.Groups[ "url "].Value);
MessageBox.Show(res.Groups[ "Text "].Value);
} 这个如何用在DELPHI中,用过TPerlRegEx的通知帮忙下