如:
www.baidu.html
www.baidu.htm
www.baidu.stml
www.baidu.xhtml
www.baidu.asp?id=1
www.baidu.aspx?id=1
www.baidu.php?id=1
www.baidu.jsp?id=1
www.baidu.asxp?id=1&type=2
------解决方案--------------------
- HTML code
<textarea id="test" style="display:none;"> www.baidu.html www.baidu.htm www.baidu.stml www.baidu.xhtml www.baidu.asp?id=1 www.baidu.aspx?id=1 www.baidu.php?id=1 www.baidu.jsp?id=1 www.baidu.aspx?id=1&type=2 www.baidu.aspx?id=1&type </textarea> <script type="text/javascript"> function $(el){ return typeof el == 'string' ? document.getElementById(el) : el; } var r = /www.+\s/g var data = $('test').value.match(r); var re = /^www\.\w+\.((?:x?html?|stml)|(?:[aj]spx?|php))(\?\w+=\w+((&\w+=\w+)*)?)?$/; for( var i = 0, len = data.length; i < len; i++ ){ var s = data[i].replace(/\s/g, ''); document.write( s + ' --------- '+ re.test(s) +'<br />' ) } </script>