比如我有很多文件:
Interior.php
Interior01.php
NISSANPage.php
NISSANPage01.php
NISSANPage03.php
Environment.php
Environment01.php
怎么获取到前缀的名字啊?比如:Environment NISSANPage Interior
Interior.php
Interior01.php
NISSANPage.php
NISSANPage01.php
NISSANPage03.php
Environment.php
Environment01.php
怎么获取到前缀的名字啊?比如:Environment NISSANPage Interior
<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>
这是js区...LZ你的需求能说得再清楚一点么...
var name = document.getElementById("test").value;
var newName = name.substring((name.lastIndexOf("\/") + 1),name.lastIndexOf("\."));
alert(newName);
}
var name =window.location;
var reg=/(.)*\/(.)*.php/.exec(name);
alert(reg[2]);
我只要获取前面的index
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]就是你想要的东西