在一个WEB源码中,规则就是两个特点的字符串。比如:
class="td_ln"> 1111111 </td>
class="td_ln"> 2222222</td>
class="td_ln"> 11sdfe11 </td>
class="td_ln"> aa       </td>
class="td_ln"> 2004-10-28 </td>
class="td_ln"> 1中村 </td>
class="td_ln"> bce中 </td>特定字符为:class="td_ln">   和  </td>如果我想要这两个特点字符中的数据,长度不定。怎么用正则表达式提取??谢谢。

解决方案 »

  1.   

    Private Sub Command1_Click()
    Dim strTemp As String
    strTemp = "class=""td_ln""> 1111111 </td>"
    MsgBox Mid(strTemp, 1, InStr(strTemp, ">"))
    MsgBox Mid(strTemp, InStrRev(strTemp, "<"))
    End Sub
      

  2.   

    try something like  s = ".........."  set re = new RegExp
      re.Pattern = "class=""td_ln"">(.*?)</td>"
      re.IgnoreCase= true
      re.Global = true
      set MC = re.Execute(s) 
      for each m in MC
    MsgBox m.SubMatches(0)
      next
    the types:MC is MatchCollection
    m is Matchsee
    http://juicystudio.com/tutorial/vb/regexp.asp
      

  3.   

    OK,现还有一个问题。比如:
        <td id="matchtime_115294" indexofmatch="14" matchtime="" nowrap>
    03:45
        </td>     <td id="matchtime_115293" indexofmatch="13" matchtime="" nowrap>
    03:45
        </td>
     像上面这些源码中,如果我想取到matchtime="" nowrap> 和</td>
    之间的内容,但是这些东西已分开了三行?不在同一行,在正则表达式中如何分行匹配呢?
    请大侠再救我一次。。谢谢。
      

  4.   

    what you still usere.Pattern = "matchtime="""" nowrap>(.*?)</td>"orre.Pattern = "matchtime="""" nowrap>\s*(.*?)\s*</td>"orre.Pattern = "<td[^>]*>(.*?)</td>"orre.Pattern = "<td[^>]*>\s*(.*?)\s*</td>"or change (.*?) to ([^<]*)
      

  5.   

    ok.谢谢,小弟还有一问题请教,Private Sub CmdGet_Click()
    On Error GoTo er:
    Dim a As New XMLHTTP
    a.Open "GET", txtaddress.Text, False
    a.send
    Text2.Text = bytes2BSTR(a.responseBody)
    Exit Sub
    er:
    MsgBox Err.Description
    End SubFunction bytes2BSTR(vIn)
            Dim strReturn
            Dim i1, ThisCharCode, NextCharCode
            strReturn = ""
            For i1 = 1 To LenB(vIn)
                ThisCharCode = AscB(MidB(vIn, i1, 1))
                If ThisCharCode < &H80 Then
                    strReturn = strReturn & Chr(ThisCharCode)
                Else
                    NextCharCode = AscB(MidB(vIn, i1 + 1, 1))
                    strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
                    i1 = i1 + 1
                End If
            Next
            bytes2BSTR = strReturn
        End Function
    用这处方法为何取不到页面中是繁体的内容?如果页面中有繁体的话我该如何取出页面的中内容?谢谢。