【发布时间】:2014-12-31 10:11:56
【问题描述】:
我有正则表达式字符串数据,但想排除子字符串
dat <- c('long_regex_other_stuff','long_regex_other_random.something')
(dat[grep('long_regex',dat)])
(dat[grep('long_regex.*(?!.*something$)',dat)])
第一个 grep 输出是预期的
"long_regex_other_stuff" "long_regex_other_random.something"
如何让第二个 grep 工作?所需的输出是
"long_regex_other_stuff"
参考:Regular expression to match a line that doesn't contain a word?
【问题讨论】: