<td id="matchtime_115287" indexofmatch="8" matchtime="" nowrap>
03:45
    </td>   <td id="matchtime_115288" indexofmatch="9" matchtime="" nowrap>
03:45
    </td>
以上源码中如何用正则表达式取出时间(03:45)??这段源码分开了三行。

解决方案 »

  1.   

    能取出来么?
    如果是asp.net ,可以使用lable显示时间,然后通过取lable的value应该可以取的。
      

  2.   

    我来告诉你  按我的方法去做
    str="<td id='matchtime_115287' indexofmatch='8' matchtime='' nowrap>
    03:45</td><td id='matchtime_115288' indexofmatch='9' matchtime='' nowrap>
    03:45</td>"
    a=split(str,"</td>")
    for i= 0 to ubound(a)-1
        a(i)=RemoveHTML(ai)
        '在这写上输出a(i)就是时间喽~~~
    next i
    '======RemoveHTML函数 去除html代码 用到了正则表达式
    function RemoveHTML(fString)
    dim re
    set re = New RegExp
    re.Global = True
    re.IgnoreCase = True
    if not isnull(fString) then
    re.Pattern = "<(.[^>]*)>"
    fString = re.Replace(fString,"")
    fString=replace(fString,"&nbsp;","")
    fString=replace(fString,vbBack,"")
    fString=replace(fString,vbTab,"")
    fString=replace(fString,vbLf,"")
    fString=replace(fString,vbCr,"")
    fString=replace(fString,vbCrLf,"")
    RemoveHTML = trim(fString)
    end if
    end function
      

  3.   

    你要取出多段,那么就根据数据进行分段.但是要保证数据完整性.下面函数中取数据的方法是根据数据源 
    "<td id="matchtime_115287" indexofmatch="8" matchtime="" nowrap>
    03:45
    </td>
    "
    进行分析的,具体根据你的数据结构来写政则就行了.
    Function GetDate(String)
    Dim reg as New RegExp
    reg.Global = True
    reg.IgnoreCase = True
    reg.Multiline = Truereg.Pattern = "<.+>(.+)<\/.+>"
    GetDate = reg.Replace(String,"$1")
    End Function
      

  4.   

    '引用:MicroSoft VBScript Regular Expressions X.X
    Dim reg As New RegExp
    Dim str1 As String
    Dim MC As Object
    Dim m As Object
    reg.IgnoreCase = True
    reg.Global = True
    reg.MultiLine = True
    str1 = "<td id='matchtime_115287' indexofmatch='8' matchtime='' nowrap>03:45</td><td id='matchtime_115288' indexofmatch='9' matchtime='' nowrap>03:45</td>"
    reg.Pattern = "<td (.*?)>(.*?)</td>"
    Set MC = reg.Execute(str1)
      For Each m In MC
            MsgBox m.SubMatches(1)
      Next
      

  5.   

    http://blog.csdn.net/vbdn/archive/2005/03/16/321378.aspx
      

  6.   

    Dim p : Set p=new RegExp
    p.Global=True
    p.IgnoreCase=True
    p.MultiLine=True
    p.Pattern="\d{2}\:\d{2}"
    p.Execute strSource
    Dim i
    For Each i In p.Matches
          Resposne.Write i
    Next