从文件路径中提取文件扩展名 [英] Extract file extension from file path

查看:130
本文介绍了从文件路径中提取文件扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在给定文件路径作为字符的情况下提取文件的扩展名?我知道我可以通过正则表达式 regexpr( \\。([[:: alnum:]] +)$,x)做到这一点,但是想知道是否存在

How can I extract the extension of a file given a file path as a character? I know I can do this via regular expression regexpr("\\.([[:alnum:]]+)$", x), but wondering if there's a built-in function to deal with this?

推荐答案

这是使用R基本工具可以轻松找到的东西。例如:??路径。

This is the sort of thing that easily found with R basic tools. E.g.: ??path.

无论如何,加载 tools 包并读取?file_ext

Anyway, load the tools package and read ?file_ext .

这篇关于从文件路径中提取文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆