俺使用表达式"<a href=([^>]+)>([^<]+)</a>"
如何访问表达式中两个子集?如网页中有内容<a href=www.sina.com.cn>新浪</a>如何能获得"www.sina.com.cn" 及 "新浪" 这两个子集呀。谢谢指教了。

解决方案 »

  1.   

    给你个例子先Private Sub Command1_Click()
    Dim reg As New RegExp
    reg.IgnoreCase = True
    reg.Global = True
    reg.MultiLine = Truestr1 = "<a href='aaa.htm'>11111</a><a href='bb.htm'>22222</a><a href='cc.htm'>33333</a>"reg.Pattern = "<a href='(.*?).htm'>(.*?)</a>"Set MC = reg.Execute(str1)  For Each m In MC
                MsgBox m.SubMatches(0)
            MsgBox m.SubMatches(1)
      Next
    End Sub
      

  2.   

    http://club.5ivb.net/UploadFile/20051704440byUID16899.rar
      

  3.   

    reg.Pattern = "<a href='(.*?).htm'>(.*?)</a>"自在飞花兄,请问括号里面为什么要用个问号?这个问号表的是什么意义?
    reg.Pattern = "<a href='(.*).htm'>(.*)</a>"

    reg.Pattern = "<a href='([^']*).htm'>([^<]*)</a>"
    这样不行吗?
      

  4.   

    自在飞花兄
    m.SubMatches(1)未找到方法及成员,俺用的是VB6.0,您说的是否适合 vb.net?还有个用group 的吧?也是适合 vb.net吧
      

  5.   

    我知道一个方法,用webbrowser中的 doument
      

  6.   

    to:phpro(killer)? 当此字符紧随任何其他限定符(*、+、?、{n}、{n,}、{n,m})之后时,匹配模式是“非贪心的”。“非贪心的”模式匹配搜索到的、尽可能短的字符串,而默认的“贪心的”模式匹配搜索到的、尽可能长的字符串。例如,在字符串“oooo”中,“o+?”只匹配单个“o”,而“o+”匹配所有“o”。若没有这个?,那么那个地址就会是:
    aaa.htm'>11111</a><a href='bb.htm'>22222</a><a href='cc我用的是vb6.0,不是.net
      

  7.   

    不用正则表达式,用这个,很简单:
    set EventElement = external.menuArguments.document
    msgbox EventElement.url+EventElement.title