从字符串初始(匹配)模式删除

问题描述 投票:0回答:1

我具有以下chr数组

v<-c("RT @name1: hello world", "Hi guys, how are you?", "Hello RT I have no text", "RT @name2: Hello!")

我只想删除位于句子开头的RT,并在另一个数组中写入w,例如结果。例如:

> w
 "@name1: hello world"    "Hi guys, how are you?"     "Hello RT I have no text"     "@name2: Hello!"

也许我可以通过软件包str_extract_all使用函数stringr,但无法将其应用于我的问题。

r regex string
1个回答
0
投票
<-  str_replace(v,"^RT","")
© www.soinside.com 2019 - 2024. All rights reserved.