解决方案 »

  1.   

    var str='<script>代码2'+
    '换行'+
    '指定内容'+
    '代码3<\/script>';var key='指定内容';var reg=new RegExp('<(script)>[^<>]*?'+key+'[^<>]*?<\/\\1>');alert(str.match(reg)[0]);
      

  2.   

    要从下面代码中匹配出
    <script type="text/javascript"><!--
    google_ad_client = "ca-pub-1066447241658620";
    /* penti */
    google_ad_slot = "8877964768";
    google_ad_width = 336;
    google_ad_height = 280;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>这段代码,我该怎么写正则表达式?
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      
    <link href="../style.css" rel="stylesheet" type="text/css" />
    <link href="../sty.css" rel="stylesheet" type="text/css" />
    <link rel="shortcut icon" href="favicon.ico" />
    </head>
    <body> 
      </div>
    <style>
     
    </style>
    <div class="main">
    <div class="left">
         <div class="search"> 
    </ul>
    <div align="center">
    <script type="text/javascript"><!--
    google_ad_client = "ca-pub-1066447241658620";
    /* CNzaobao468x60, 创建于 09-4-30 */
    google_ad_slot = "7704979228";
    google_ad_width = 468;
    google_ad_height = 60;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    </div>          </div>
        </div>
        <div class="left_box">
    <div class="my_ser_title">我们提供的服务</div>
    <div  class="my_ser">
    <ul> 
          </ul> 
       </div>
             <div align="center">
    <script type="text/javascript"><!--
    google_ad_client = "ca-pub-1066447241658620";
    /* CNzaobao468x60, 创建于 09-4-30 */
    google_ad_slot = "7704979228";
    google_ad_width = 468;
    google_ad_height = 60;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> 
    </script>
    </div>     </div>
    </div>
        <div class="right">
         <div class="right_box">
    <script type="text/javascript"><!--
    google_ad_client = "ca-pub-1066447241658620";
    /* penti */
    google_ad_slot = "8877964768";
    google_ad_width = 336;
    google_ad_height = 280;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    </div>
            <div class="right_box"><!-- Baidu Button BEGIN --> 
        </ul>
    </div>
        </div> <div id="foot">
    <span><p><a href="http://www.Mefancy.com" target="_blank">Word Counter</a> | <a href="http://www.ThinkCalculator.com" target="_blank">ThinkCalculator</a><script type="text/javascript"> 
    var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
    document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3Fcb095cfc72cf799617b332336ec1f073' type='text/javascript'%3E%3C/script%3E"));
    </script>
    </p></span>
    </div>
    </div>
    </body>
    </html>
      

  3.   

    等待高手指点,我现在的表达式提取的内容不是
    <script type="text/javascript"><!--
    google_ad_client = "ca-pub-1066447241658620";
    /* penti */
    google_ad_slot = "8877964768";
    google_ad_width = 336;
    google_ad_height = 280;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>,结尾没问题,可开头却是 <script type="text/javascript"><!--
        google_ad_client = "ca-pub-1066447241658620";
        /* CNzaobao468x60, 创建于 09-4-30 */
        google_ad_slot = "7704979228";
        google_ad_width = 468;
        google_ad_height = 60;
        //-->
        </script>
        <script type="text/javascript"
        src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
        </script>
    </div>                </div>
            </div>
            <div class="left_box">
                    <div class="my_ser_title">我们提供的服务</div>
        <div  class="my_ser">
        <ul> 
          </ul> 
       </div>
                    <div align="center">
        <script type="text/javascript"><!--
    google_ad_client = "ca-pub-1066447241658620";
    /* CNzaobao468x60, 创建于 09-4-30 */
    google_ad_slot = "7704979228";
    google_ad_width = 468;
    google_ad_height = 60;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> 
    </script>
    </div>        </div>
        </div>
            <div class="right">
            <div class="right_box">
                <script type="text/javascript"><!--
                google_ad_client = "ca-pub-1066447241658620";
                /* penti */
                google_ad_slot = "8877964768";
                google_ad_width = 336;
                google_ad_height = 280;
                //-->
                </script>
                <script type="text/javascript"
                src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
                </script>
      

  4.   

    正则表达式完整教程 http://www.itzlk.com/jskernel/456.jhtml