【发布时间】:2019-07-12 13:34:44
【问题描述】:
我有下面这句话
review <- C("1a. How long did it take for you to receive a personalized response to an internet or email inquiry made to THIS dealership?: Approx. It was very prompt however. 2f. Consideration of your time and responsiveness to your requests.: Were a little bit pushy but excellent otherwise 2g. Your satisfaction with the process of coming to an agreement on pricing.: Were willing to try to bring the price to a level that was acceptable to me. Please provide any additional comments regarding your recent sales experience.: Abel is awesome! Took care of everything from welcoming me into the dealership to making sure I got the car I wanted (even the color)! ")
我想删除之前的所有内容:
我试过下面的代码,
gsub("^[^:]+:","",review)
但是,它只删除了以冒号结尾的第一句
预期结果:
Approx. It was very prompt however. Were a little bit pushy but excellent otherwise Were willing to try to bring the price to a level that was acceptable to me. Abel is awesome! Took care of everything from welcoming me into the dealership to making sure I got the car I wanted (even the color)!
任何帮助或建议将不胜感激。谢谢。
【问题讨论】:
-
你的问题不清楚。之前的一切都可以包括所有的字符。是一个句子吗?
-
所以你只想删除
1a.、2f.、2g.、:?每行的这些字符是否相同? -
对不起,我的意思是我想摆脱句子中的所有问题,只保留回复。就我而言,问题以冒号结尾,这就是为什么我在冒号之前提到了所有内容
-
试试
gsub("(?:\\d+[a-zA-Z]\\.)?[^.?!:]*[?!.]:\\s*", "", review) -
如果您能解释一下正则表达式,那就太好了。