我怎么将C:\Documents and Settings\Administrator\桌面\新建文件\index.html这个路径中的index.html截取掉,只获得C:\Documents and Settings\Administrator\桌面\新建文件\呢!!!!谢谢啦
------解决方案--------------------
<textarea onblur= "mm(this.value) " style= "width: 100%; height: 100px "> C:\Documents and Settings\Administrator\桌面\新建文件\index.html </textarea>
<SCRIPT LANGUAGE= "JavaScript ">
<!--
function mm(url)
{
if(/^(.+(\\|\/))[^\\\/]+/.test(url)) alert(RegExp.$1);
}
//-->
</SCRIPT>
------解决方案--------------------
这个式子/[^\\]+$/
使用方法如下:
<script type= "text/javascript ">
var s = 'C:\\Documents and Settings\\Administrator\\桌面\\新建文件\\index.html ';
alert(s.replace(/[^\\]+$/, " "));
</script>