使用通配符删除 Phrase
Removal of Phrase using wildcards
我正在搜索如何使用通配符作为语料库部分删除标准的一部分。我无法在 SO 或 google 上找到与此问题相关的任何内容。
目的:分析大型标准化笔记数据集,其中员工输入被分成文本部分。
示例数据:
***Date; Area: asdfwerqw Detail: xxxxx Requested Action: xxxxxx Assigned to: John Doe
要提取以供分析的部分:
Detail:xxxxx Requested Action:xxxxxx
详细信息之前的项目数可能更多。此外,分配给:可能不会出现。
如果没有更多示例和详细信息,很难说清楚,但您可能会想要使用正则表达式和可选项:
library(stringr)
text <- c("***Date; Area: asdfwerqw Detail: xxxxx Requested Action: xxxxxx Assigned to: John Doe")
str_extract_all(text, c("Detail(.*?)(?=Requested Action:)", "Requested Action:((.*?)(?=Assigned to:))?"))
# [[1]]
# [1] "Detail: xxxxx "
#
# [[2]]
# [1] "Requested Action: xxxxxx "
我正在搜索如何使用通配符作为语料库部分删除标准的一部分。我无法在 SO 或 google 上找到与此问题相关的任何内容。
目的:分析大型标准化笔记数据集,其中员工输入被分成文本部分。
示例数据:
***Date; Area: asdfwerqw Detail: xxxxx Requested Action: xxxxxx Assigned to: John Doe
要提取以供分析的部分:
Detail:xxxxx Requested Action:xxxxxx
详细信息之前的项目数可能更多。此外,分配给:可能不会出现。
如果没有更多示例和详细信息,很难说清楚,但您可能会想要使用正则表达式和可选项:
library(stringr)
text <- c("***Date; Area: asdfwerqw Detail: xxxxx Requested Action: xxxxxx Assigned to: John Doe")
str_extract_all(text, c("Detail(.*?)(?=Requested Action:)", "Requested Action:((.*?)(?=Assigned to:))?"))
# [[1]]
# [1] "Detail: xxxxx "
#
# [[2]]
# [1] "Requested Action: xxxxxx "