Remove path from file name
显示 更早的评论
Hello!
There's probably a simple tool for this, but I can't find it:
Have a string for a file name that includes the full path, like:
C:\Users\DougAnderson\Documents\MATLAB\SHtest\sig hole 1.xlsx
where the last part (the actual file name) may contain spaces. I would like to change this to, for example
sig hole 1
Thanks
Doug
采纳的回答
更多回答(2 个)
Azzi Abdelmalek
2014-12-11
s='C:\Users\DougAnderson\Documents\MATLAB\SHtest\sig\hole 1.xlsx'
out=regexp(s,'(?<=\\)[^\\]+$','match')
类别
在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!