提取特定的字符串

发布于 2025-02-05 17:42:14 字数 621 浏览 1 评论 0原文

我已经从各种床单中加载了R中的数据,在下面您可以看到床单的名称。您可以在下面看到数据和代码:

df<-data.frame(
                  Tables=c("Export_A1.xlsx","Export_A2.xlsx","Export_A10.xlsx"))

”在此处输入图像描述”

所以现在我想提取特定名称,换句话说,我想删除文本“ export_”和“ .xlsx”。下面您可以看到一个示例

”在此处输入图像描述”

那么有人可以帮助我如何解决这个问题吗?

I have already loaded the data in R from various sheets, below you can see the names of the sheets. Below you can see the data and code:

df<-data.frame(
                  Tables=c("Export_A1.xlsx","Export_A2.xlsx","Export_A10.xlsx"))

enter image description here

So now I want to extract specific names, or in other words, I want to remove the text "Export_" and ".xlsx". Below you can see an example

enter image description here

So can anybody help me how to solve this problem ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薔薇婲 2025-02-12 17:42:15

您可以使用以下代码:

df$Tables <- gsub(".*[_]([^.]+)[.].*", "\\1", df$Tables)

df

输出:

  Tables
1     A1
2     A2
3    A10

You can use the following code:

df$Tables <- gsub(".*[_]([^.]+)[.].*", "\\1", df$Tables)

df

Output:

  Tables
1     A1
2     A2
3    A10
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文