首页 > 解决方案 > 我想要在包含使用 R 的文本的列中的第一个句号之后的单词

问题描述

我想要第二句话的文字。

text="I need to go to mall today. I want to purchase clothes. Also, I want to buy shoes."

预期结果:

I want to purchase clothes. Also, I want to buy shoes.

标签: r

解决方案


我们也可以stringr::str_match用来捕获第一个点之后的所有内容。

stringr::str_match(text, "\\.(.*)")[, 2]
#[1] " I want to purchase clothes. Also, I want to buy shoes."

[, 2]是获取捕获组。


推荐阅读