正则为: /<(.*)>.*<\/\1>/例子: Function RegExpTest(patrn, strng) Dim regEx, Match, Matches ' 建立变量。 Set regEx = New RegExp ' 建立正则表达式. regEx.Pattern = patrn ' 设置模式. regEx.IgnoreCase = True ' 设置是否区分字母的大小写。 regEx.Global = True ' 设置全程可用性。 Set Matches = regEx.Execute(strng) ' 执行搜索。 For Each Match in Matches ' 循环遍历Matches集合。 RetStr = RetStr & Match.Value Next RegExpTest = RetStr End Function //使用: re="<td">.*<\/td>" value=RegExpTest(re,Stng)
to phoubes(amo):你那个不行了,找到的内容很多。不是想要的。 在SCRIPT56.chm上面有to yicikou(伊静) : td内的内容不是固定不变的,我只需要读出<a> </a>间如果没有<a>的就读出<td></td>间的,其它内容全部不要
print_r($array);
还有可能有另一种情况的处理,是同有link的。比如:
<tr><td>Test String</td></tr>
先截<td>右边的,再截</td>左边的。 呵呵呵
Test String
或
<a style='color: #0000FF' href='/test.php?id=1&n=test&t=70'>Test String</a>++++++++++++++++++++++++++++++
我的想法是先对比"<td><font><a style='color: #0000FF' href='/test.php?id=1&n=test&t=70'>"这一部分,如果正确就开始截取,当遇到"</a>(27/12/03 15:00 GMT)</font><br></td>"这个时,就停止截取.
Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches ' 建立变量。
Set regEx = New RegExp ' 建立正则表达式.
regEx.Pattern = patrn ' 设置模式.
regEx.IgnoreCase = True ' 设置是否区分字母的大小写。
regEx.Global = True ' 设置全程可用性。
Set Matches = regEx.Execute(strng) ' 执行搜索。
For Each Match in Matches ' 循环遍历Matches集合。
RetStr = RetStr & Match.Value
Next RegExpTest = RetStr
End Function
//使用:
re="<td">.*<\/td>"
value=RegExpTest(re,Stng)
在SCRIPT56.chm上面有to yicikou(伊静) :
td内的内容不是固定不变的,我只需要读出<a> </a>间如果没有<a>的就读出<td></td>间的,其它内容全部不要