<li><p>当前可用分红:<span class="red2">0.28</span>元</p><a href="/New_MyAccount/Cash_MelonNew.aspx"><img src="/images/check_btn.jpg"  class="xq"/></a></li>如何取"当前可用分红"的0.28显示在text1上谢谢哦`

解决方案 »

  1.   

    因为点只有一个或者没有所以用.?,表达式为:\d+\.?\d+ 但是如果其他地方也有价格表示的话会都匹配出来造成结果错误,所以需要带上前面的汉字。'此代码由“正则测试工具 v1.1.34”自动生成,请直接调用TestReg过程Private Sub TestReg()
        Dim strData As String
        Dim reg As Object
        Dim matchs As Object, match As Object    strData = "<li><p>当前可用分红:<span class=""red2"">0.28</span>元</p><a href=""/New_MyAccount/Cash_MelonNew.aspx""><img src=""/images/check_btn.jpg"" class=""xq""/></a></li>"    Set reg = CreateObject("vbscript.regExp")
        reg.Global = True
        reg.IgnoreCase = True
        reg.MultiLine = True
        reg.Pattern = "<p>当前可用分红:<span class=""red2"">(.+?)</span>元"
        Set matchs = reg.Execute(strData)
        For Each match In matchs
            'Debug.Print match.Value
            Debug.Print match.SubMatches(0)
        Next
    End Sub