【发布时间】:2013-09-10 13:06:49
【问题描述】:
只有当and/ERT没有被“/V”在一个单词之后在
text <- c("faulty and/ERT something/VBN and/ERT else/VHGB and/ERT as/VVFIN and/ERT not else/VHGB propositions one and/ERT two/CDF and/ERT three/ABC")
# my try - !doesn't work
> strsplit(text, "(?<=and/ERT)\\s(?!./V.)", perl=TRUE)
^^^^
# Exptected return
[[1]]
[1] "faulty and/ERT something/VBN and/ERT else/VHGB and/ERT as/VVFIN and/ERT"
[2] "not else/VHGB propositions one and/ERT"
[3] "two/CDF and/ERT"
[4] "three/ABC"
【问题讨论】:
-
如果它直接在可能的匹配之后,您是否希望它失败。即:
and/ERT something/VBN应该失败,and/ERT something something/VBN不应该失败?引用@smerny。 -
Alex,您的最新编辑(str 和 return)仍然与我的正则表达式匹配:regexr.com?369f3