日期:2014-05-16  浏览次数:20444 次

正则如何获取url
urls[i]='/art/303578.html';headers[i]=
..................
urls[i]='/art/403578.html';headers[i]=


如何取到 /art/403578.html

谢谢

------解决方案--------------------
HTML code

<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="gb2312" />
        <title></title>
        <style>
        </style>
    </head>
    <body>
        <div id="t">
urls[i]='/art/303578.html';headers[i]=
..................
urls[i]='/art/403578.html';headers[i]=
        </div>
        <script>
            function $(el){
                return typeof el == 'string' ? document.getElementById(el) : el;
            }
            var str = $('t').innerHTML;
            var re = /urls\[i\]='([^']+?)'/gi;
            var tmp = [];
            str.replace(re, function($){
                re.test($);
                re.lastIndex = 0;
                tmp.push( RegExp.$1 );
            })
            alert( tmp )
        </script>
    </body>
</html>

------解决方案--------------------
/'([^\']*?)'/
------解决方案--------------------
urls.*?=['"]?(.*?html)
------解决方案--------------------
探讨

HTML code

<!DOCTYPE HTML>
<html>
<head>
<meta charset="gb2312" />
<title></title>
<style>
</style>
</head>
<body>
<div id="t">
urls[i]='/art/3035……