我在R.删除R中的单词开头的句子吗?
"RT @SportClipsUT125: #SavingLivesLooksGood with #RedCross. Donate this month & Get free haircut cpn. https://somewebsite https://somewebsite…"
如何删除所有链接鸣叫的文字是这样的(除去重复的鸣叫),因此下面的鸣叫实际上返回下面的字符串?
"RT @SportClipsUT125: #SavingLivesLooksGood with #RedCross. Donate this month & Get free haircut"
我已经试过这样:
gsub('https*','',test_str)
但它返回
"RT @SportClipsUT125: #SavingLivesLooksGood with #RedCross. Donate this
month & Get free haircut cpn. ://somewebsite ://somewebsite…"
你需要把量词上要重复的字符。 '\\ S'只是一个空格字符:'gsub('http \\ S *','','RT @ SportClipsUT125:#SavingLivesLooksGood with #RedCross。Donate this month&Get free haircut cpn。https:// somewebsite https:// somewebsite ...“)' – alistaire
也许你可以再次向twitter发送相同的查询,并附加-RT(区分大小写)。这将删除转发。 – knb
谢谢@alistaire这实际上工作!那么你的代码在做什么实际上是在https和一个空间后删除所有内容? –