<script>
function checkfrom(str){
     str = str.replace(/"/,"")
     if(str.indexOf("<")>0)
         str = str.substr(str.indexOf("<")+1)
     str = str. replace(">","")
     checkfrom = str
}
checkfrom('123<adfdfe>')
alert(checkfrom)
</script>

解决方案 »

  1.   

    他上面写得结果是对的,不过这样写更直观
    <script>
    function checkfrom(str){
         str = str.replace(/"/,"");
         if(str.indexOf("<")>0);
             str = str.substr(str.indexOf("<")+1);
         str = str. replace(/>/,"");
         return str;
    }
    var str=checkfrom('123<adfdfe>');
    alert(str);
    </script>
      

  2.   

    http://expert.csdn.net/Expert/topic/1945/1945960.xml?temp=.8768885
    先谢谢你的回复。
    我是这么用的,但是有问题:<html>
    <head>
    <script>
    function checkfrom(str){
         str = str.replace(/"/,"")
         if(str.indexOf("<")>0)
             str = str.substr(str.indexOf("<")+1)
         str = str. replace(">","")
         checkfrom = str
        
    }function as()
    {
    form1.a2.value=checkfrom('*"<[email protected]');
    }</script>
    </head>
    <body>
    <form name=form1>
    <input type=text name=a2>
    <input type=button onclick="as()">
    </form>
    </body>
    </html>但是、第一次点button时,a2的值是undefined(未定义),再点就报错误了,怎么回事?谢谢!