node.js中的path.basename方法使用说明
2014-12-09 09:09
1356 查看
方法说明:
提取出用 ‘/' 隔开的path的最后一部分。(8详见例子)
语法:
复制代码 代码如下:path.basename(p, [ext])
由于该方法属于path模块,使用前需要引入path模块(var path= require(“path”) )
接收参数:
p 要处理的path
ext 要过滤的字符
例子:
复制代码 代码如下:var path= require("path");
path.basename('/foo/bar/baz/asdf/quux.html')
// returns
'quux.html'
path.basename('/foo/bar/baz/asdf/quux.html', '.html')
// returns
'quux'
var a = path.basename('/foo/bar/baz/asdf/', '.html');
// returns
'asdf'
您可能感兴趣的文章:
相关文章推荐
- node.js中的path.basename方法使用说明
- node.js中的path.delimiter方法使用说明
- node.js中的path.sep方法使用说明
- node.js中的path.resolve方法使用说明
- node.js中的path.isAbsolute方法使用说明
- node.js中的path.sep方法使用说明
- node.js中的path.resolve方法使用说明
- node.js中的path.isAbsolute方法使用说明
- node.js中的path.extname方法使用说明
- node.js中的fs.realpathSync方法使用说明
- node.js中的path.extname方法使用说明
- node.js中的path.normalize方法使用说明
- node.js中的path.normalize方法使用说明
- node.js中的path.dirname方法使用说明
- node.js中的path.resolve方法使用说明
- node.js中的path.delimiter方法使用说明
- node.js中的fs.realpathSync方法使用说明
- node.js中的path.dirname方法使用说明