str = "http:\/\/www.xxx.com\/123456"    字符串求个能匹配的正则表达式。123456代表网址后面的一个内容,可以(.*?)表示,主要是前面部分。

解决方案 »

  1.   

    /http://www.\w*.com/   
      

  2.   

    /http://www.\w*.com/意思是说,\/\/这些不用去管他?按照正常的网址直接匹配?注:http:\/\/www.xxx.com\/ 这个就已经是等待匹配的字符串了,不是表达式。想半天不知道如何转译符号……
      

  3.   

    /http://((.*)/(.*))/
    批配后,alert下数组就知道了
      

  4.   


    var reg=RegExp("(^[a-zA-Z:\.\/])(\.*$)","ig");
    var d="http://www.xxx.com/123456";
    alert(reg.test(d));
      

  5.   

    i have done it by myself,but thanks all the same!give the points and ending the problem.
      

  6.   

    是不是匹配红色部分 http://www.xxx.com/123456, 如下是匹配红色部分的
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head>
    <script language="javascript" type="text/javascript">
    function doCHK()
    {
    var reg=RegExp(/(http:\/\/www\.)(\w*)\.com\/(.*$)/ig);
    var url; //="http://www.xxx.com/123456";
    url=document.getElementById("content1").value;
    if(reg.test(url))
    alert("匹配");
    else
    alert("不匹配");
    }
    </script>
    <body>
    <p>
    正则匹配问题<br>
    <input name="content1" type="text" id="content1" value="http://www.xxx.com/123456" size="60">
    <input name="BTN01" value="Test" type="button" onClick="javascript:doCHK();">
    </p>
    </body>
    </html>