【发布时间】:2013-04-25 18:19:18
【问题描述】:
只要before 和after 字符串没有正则表达式的特殊字符,以下代码就可以工作:
before <- 'Name of your Manager (note "self" if you are the Manager)' #parentheses cause problem in regex
after <- 'CURRENT FOCUS'
pattern <- paste0(c('(?<=', before, ').*?(?=', after, ')'), collapse='')
ex <- regmatches(x, gregexpr(pattern, x, perl=TRUE))
R 是否具有转义正则表达式中使用的字符串的功能?
【问题讨论】: