【发布时间】:2020-01-26 06:51:36
【问题描述】:
我有一个匹配的字符串。需要查找匹配多个字符串(全部/全部)和任意顺序的文本:
Text1 : "I have no intention to make illegal parking along the road or cause obstruction."
Text2 : "I have no intention to make illegal parking along the road or cause damage."
我的代码:
mynames=c("illegal parking" , "obstruction")
grepl(paste(mynames, collapse='|'), Text1, ignore.case=TRUE)
当我通过 Text1 和 Text2 - 我得到 TRUE - 对于两者;
但是我需要TRUE 为Text1 和FALSE 为Text2。当只有两个字符串都存在时,它应该会产生 - 它可以在文本中以任何顺序出现。
【问题讨论】: