【发布时间】:2016-10-25 05:55:10
【问题描述】:
我正在尝试获取句子中两个单词之间的文本。 例如句子是-
x <- "This is my first sentence and This is my second sentence"
现在我想要这样的输出:
[1] first second
这是我尝试过的,但它不起作用
gsub('^.*This is my \\s*|\\s*sentence.*$', '', x)
【问题讨论】:
我正在尝试获取句子中两个单词之间的文本。 例如句子是-
x <- "This is my first sentence and This is my second sentence"
现在我想要这样的输出:
[1] first second
这是我尝试过的,但它不起作用
gsub('^.*This is my \\s*|\\s*sentence.*$', '', x)
【问题讨论】:
试试这个:
x <- "This is my first sentence and This is my second sentence"
gsub('.*?This is my (\\w*?) sentence.*?', '\\1 ', x)
【讨论】: