Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用正则表达式(在 Javascript 中)从以下路径获取最后一个文件夹名称(没有文件名)?
c:\folder1\folder2\last_folder\filename.ext
我正在寻找最有效的解决方案。
提前致谢
var path = 'c:\\folder1\\folder2\\last_folder\\filename.ext'; var folder = path.replace( /.+\\(.+)\\[^\\]+$/, '$1' );