【发布时间】:2011-04-09 17:34:49
【问题描述】:
我想获取一个不带路径的文件名(如果它是字符串的一部分)以及扩展名。
例如:
/path/to/file/fileName.txt # results in "fileName"
fileName.txt # results in "fileName"
/path/to/file/file.with.periods.txt # results in "file.with.periods"
所以基本上,我想删除之前的任何内容,包括最后一个“/”(如果存在)以及最后一个“。”以及它之后的任何元字符。
对于这样一个新手问题,我很抱歉,但我是 perl 的新手。
【问题讨论】:
标签: regex perl file-extension filepath