gpt4 book ai didi

regex - 从R中的url路径获取文件名

转载 作者:行者123 更新时间:2023-12-04 16:27:24 26 4
gpt4 key购买 nike

我想从 R 中的 url 中提取文件名。现在我按如下方式执行,但也许它可以像在 python 中那样做得更短。假设路径只是字符串。

path="http://www.exanple.com/foo/bar/fooXbar.xls"

在 R:
tail(strsplit(path,"[/]")[[1]],1)

在 Python 中:
path.split("/")[-1:]

也许一些sub,gsub解决方案?

最佳答案

有一个功能...

basename(path)
[1] "fooXbar.xls"

关于regex - 从R中的url路径获取文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18788493/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com