日期:2014-05-16  浏览次数:20424 次

请教请教一下!!!
D:\eclipse\apache-tomcat-7.0.23\webapps\LastProject\uploads\20125914035913.jpg


比如我只想得到字符串 uploads\20125914035913.jpg  

应该怎么做??谢谢

------解决方案--------------------
HTML code

<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="gb2312" />
        <title></title>
    </head>
    <body>
        <div id="test">
            D:\eclipse\apache-tomcat-7.0.23\webapps\LastProject\uploads\20125914035913.jpg
        </div>
        <script>
            function $(el){
                return typeof el == 'string' ? document.getElementById(el) : el;
            }
            var s = $('test').innerHTML;    
            var r = /uploads\\\d+\.jpg/;
            alert(s.match(r))
        </script>
    </body>
</html>

------解决方案--------------------
JScript code
var str = 'D:\\eclipse\\apache-tomcat-7.0.23\\webapps\\LastProject\\uploads\\20125914035913.jpg';
var ar = str.split('\\');
var result = ar[ar.length - 2] + '\\' + ar[ar.length - 1];
alert(result);