function get_ip_port(str)
{
alert(str);
res = str.match(/(?:\d{1,3}\.){3}\d{1,3}/);
alert(res);
}

解决方案 »

  1.   

    function get_ip_port(str)
    {
    res = str.match(/(?:\d{1,3}\.){3}\d{1,3}/);
    return res[0];
    }
      

  2.   

    汗一个,搞了一下午,还是套不出来
    想要做到的是得到一个IP后,得到对应的端口,然后,合成ip:port的字符返回.
    Public Function get_ip_port(pi_str)
        Dim re, re2, s_port As String
        re = "(?:\d{1,3}\.){3}\d{1,3}"
        re2 = ""
        Dim o_str, o_str2 As String    Dim regEx, Match, Matches, i        ' 建立变量。
        Dim regEx2, Match2, Matches2         ' 建立变量。
        
        Set regEx = New RegExp
        Set regEx2 = New RegExp     ' 建立正则表达式。
        
        regEx.Pattern = re         ' 设置模式。
        regEx.Global = True            ' 设置全局可用性
        'regEx2.Pattern = re2         ' 设置模式。
        'regEx2.Global = True            ' 设置全局可用性
        
        Set Matches = regEx.Execute(pi_str)      ' 执行搜索
        For Each Match In Matches         ' 遍历 Matches 集合。
            o_str = o_str + Match.Value + ":"
            re2 = CStr(Match.Value) + ".*(</td>){1}.*(<td){1}.*d{1,5}" '*** 下面是想得到 port 端口的 正则,可惜搞来搞去都不成
            regEx2.Pattern = re2         ' 设置模式。
            regEx2.Global = True            ' 设置全局可用性
             Set Matches2 = regEx.Execute(pi_str)
            For Each i In Matches2
                s_port = i.Value
            Next
            o_str = o_str + s_port + ","
        Next
        MsgBox o_str
        get_ip_port = o_str
    End Function
    目的还是说了,就是对一网页读取,得到ip:port这样格式的字符串,是一些发布代理的网页来的...各位达人帮帮忙,谢谢
      

  3.   

    要的就是:
    能匹配 这样的格式的.字符串
    213.224.242.81</td> ...... <td ..... 8080 ....</td>然后得出
    194.57.157.2:8080
    谢谢
      

  4.   

    <body>
    <div id='t'>
    <TR class='menulink1' align='middle' bgColor='#e3e6ea'>
    <TD align='left' height='17'>194.57.157.2</TD>
    <TD height='17'>8080</TD>
    <TD>high anonymity</TD>
    <TD>France</TD>
    <TD>2006-04-11</TD>
    <TD><A class='small' href='....'>Whois</B></A></TD>
    </TR>
    </div>
    <script>
    alert(t.innerHTML.replace(/<[^>]+>/g, '').match(/(\d+\.){3}\d+ (\d+)/)[0].replace(' ',':'));
    </script>
    </body>