result = reg_match_all("<tr><td width=77%>.*?</td></tr>",str)
for i = 0 to ubound(result)
alert result(i)
next
function reg_match_all(patrn,strng)
Dim regEx,Matches,i,aReturn()
Set regEx = New regExp
regEx.Pattern = patrn
regEx.IgnoreCase = False
regEx.Global = True
Set Matches = regEx.Execute(strng)
Redim aReturn(Matches.Count-1)
For i = 0 To Matches.Count-1
aReturn(i) = Matches(i).value
Next
Set Matches = nothing
Set regEx = nothing
reg_match_all = aReturn
end function
</SCRIPT>
为同C注释一样,其中的分隔符如多于一个字符时,则编写正则表达式就要困难许多。例
如串集合b a. . .(没有a b). . . a b(用b a. . . ab 代替C的分隔符/ * . . . * /,这是因为星号,有时还有
前斜杠要求特殊处理的元字符)。不能简单地写作:
b a (~( a b ) ) * a b
由于“非”运算通常限制为只能是单个字符而不能使用字符串。可尝试用~a、~b和~( a | b )为
~( a b )写出一个定义来,但这却没有多大用处。其中的一个解是:
b * ( a *~( a | b ) b * ) * a *
然而这很难读取(且难证明是正确的)。因此,C注释的正则表达式是如此之难以至于在实际
中几乎从未编写过。实际上,这种情况在真正的扫描程序中经常是通过特殊办法解决的,本章
后面将会提到它。