var text = "你上面的数据<html>\r\n<head>...";
var newText = text.replace(/^[\s\S]*<html>/,"<html>");
alert(newText); // <html>
                // <head>

解决方案 »

  1.   

    <b>Notice </b>:  Undefined index:  radio in <b>E:\web\ibe\ibe_service\index.php </b> on line <b>71 </b> <br /> 
    <html> 
    <head> 
    ...
    </html>
    <ttt>
    那有如何去除<html></html> 之外 的所有字符串呢,因为他们都不固定,是返回值,谢谢了
      

  2.   

    var str = "<b>Notice </b>:  Undefined index:  radio in <b>E:\web\ibe\ibe_service\index.php </b> on line <b>71 </b> <br />"
     + "<html>"
    +"<head>"
    +"..."
    +"</html>"
    +"<ttt> ";
    alert("原字符串="+str);
    str = str.substring(str.indexOf("<html>"),str.indexOf("</html>")+7);
    alert("目标字符串="+str);
      

  3.   

    不明白你是什么意思,你在创建html的时候将属性在精心创建,就不会有上面的问题了
      

  4.   

    str.replace(/.*(<html>.*?<\/html>).*/gi,"$1");----------------------------------------
    找猎头把自己卖个好价钱!
      

  5.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>
    <script language="JavaScript">
    window.onload=function(){
    var o=document.getElementById("text1");
    alert(o.value.replace(/^(.|\s)*?(?=\<html\>)/gm,""));
    }
    </script>
    <body>
    <textarea id="text1" rows="20" cols="50" wrap="off">HTTP/1.1 200 OK
    Connection: close
    Date: Mon, 29 Dec 2008 06:38:41 GMT
    Server: Microsoft-IIS/6.0
    X-Powered-By: ASP.NET
    X-Powered-By: PHP/5.1.4
    Content-type: text/html<!--Array
    (
        [txtDepDate] => 2008-12-30
        [txtDepPort] => SHA
        [txtArrPort] => DLC
        [txtAirways] => ALL
        [search_number] => 1
    )
    --> <br />
    <b>Notice </b>:  Undefined index:  txtBackDate in <b>E:\web\ibe\ibe_service\index.php </b> on line <b>68 </b> <br />
    <br />
    <b>Notice </b>:  Undefined index:  radio in <b>E:\web\ibe\ibe_service\index.php </b> on line <b>71 </b> <br />
    <html>
    <head></textarea>
    </body>
    </html>