【问题标题】:Remove exact alphanumeric string from text in R/Python [duplicate]从R / Python中的文本中删除精确的字母数字字符串[重复]
【发布时间】:2018-07-17 10:00:15
【问题描述】:

“字符串?是由一堆字符串组成的,但问题是删除了单词字符串中的问号?没有删除其他问号。有人可以看看吗?”

在上面的文字中,我必须改变“字符串?”到“字符串”。但我不希望声明失去其余的 ?在正文中。

结果文本应为: “字符串是由一堆字符串组成的,但问题是删除了单词字符串中的问号而不删除其他问号。有人可以看看吗?”

我尝试了 gsub、string_replace 和许多其他方法,它们最终删除或替换了单词并仍然保留“?”

【问题讨论】:

  • 您也可以提及您的尝试吗?我的意思是在代码中
  • 第二个问号是什么
  • “这是愚人节玩笑吗?” ......它的二月! “你去” python 教程......用知识渊博的背景信息给 Tarun 带来负担。其次......无论是python还是R中的解决方案......都是具体的。
  • 你告诉他@ZF007!在 R/python 中询问解决方案都不是问题,所以问题值得比这更多的努力! Tarun - 正如 Vikas 所说,请发布您尝试过的代码。另外,请查收How to ask a question on SO
  • “我试过......”,你的问题中这个尝试在哪里?

标签: python r regex text-mining


【解决方案1】:
string.replace('string?', 'string')

给予:

'The string is made up a load of strings but the problem is the removal of 
question mark in the word string without removing the other question marks. 
can anybody have a look?'

【讨论】:

    猜你喜欢
    • 2021-06-05
    • 1970-01-01
    • 1970-01-01
    • 2017-03-11
    • 1970-01-01
    • 2022-09-23
    • 1970-01-01
    • 1970-01-01
    • 2022-01-22
    相关资源
    最近更新 更多