比如我有很多文件:
Interior.php
Interior01.php
NISSANPage.php
NISSANPage01.php
NISSANPage03.php
Environment.php
Environment01.php
怎么获取到前缀的名字啊?比如:Environment  NISSANPage  Interior

解决方案 »

  1.   

    现写了一个,lz参考一下<html>
    <head></head>
    <script>
    function substr(){
    var name = document.getElementById("test").value;
    var l = name.length;
    var newName = name.substr(0,l-4);
    alert(newName);
    }
    </script>
    <body>
    <input type = 'text' id = 'test' />
    <input type = 'button' onclick = 'substr()' value = '查看'/>
    </body>
    </html>
      

  2.   

    str.subString(0,str.lastIndexOf("\\."));
      

  3.   

    额..
    这是js区...LZ你的需求能说得再清楚一点么...
      

  4.   

    是不是这样的啊?http://www.baidu.com/index.php要获取 index ?
      

  5.   

    那就改一下~function substr(){
    var name = document.getElementById("test").value;
    var newName = name.substring((name.lastIndexOf("\/") + 1),name.lastIndexOf("\."));
    alert(newName);
    }
      

  6.   


    var name =window.location;
    var  reg=/(.)*\/(.)*.php/.exec(name);
            alert(reg[2]);
      

  7.   

    是啊.但是也有http://www.baidu.com/index1.php,http://www.baidu.com/index2.php,http://www.baidu.com/index3.php
    我只要获取前面的index
      

  8.   


    var re = /\/([a-zA-Z]{1,})(\d){0,}\.([a-zA-Z]{1,})$/gi;
    var arr = re.exec(window.location.href);
    alert(arr[1]);  //arr[1]就是你想要的东西