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

正则表达式 怎么在html中拿到值
<a href='/Patent/01127847' target='_blank'>
<a href='/Patent/01127821' target='_blank'>
<a href='/Patent/01127832' target='_blank'>
还有其他的标签省略了

正则要怎么样拿到01127847,01127821,01127832

求高人指点

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

<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="gb2312" />
        <title></title>    
        <style>
        </style>        
    </head>
    <body>
        <div>
<a href='/Patent/01127847' target='_blank'>
<a href='/Patent/01127821' target='_blank'>
<a href='/Patent/01127832' target='_blank'>
        </div>
        <script>
            function $t(name, cot){
                cot = cot || document;
                return cot.getElementsByTagName(name);
            }
            var str = $t('div')[0].innerHTML;
            var re = /.+?Patent\/(\d+).+?/gi;
            var tmp = [];
            str.replace(re, function($){
                re.test($);
                re.lastIndex = 0;
                tmp.push( RegExp.$1 );
            })
            alert(tmp)
        </script>
    </body>
</html>