Xpath - 在单词的第5个和第6个字符中标识包含字符串“AB”的文本

时间:2017-03-30 02:53:19

标签: xpath

我正在尝试编写匹配的 XPath 规则,但我似乎无法用第5和第6位的确切字母指出单词。

'qwer ab qwert'中的'ab'

N <- as.integer(length(proteins.vec))

funOP <- function() {
  do.call(rbind, lapply(peptides.vec, function(p) grepl(p, proteins.vec)))
}

funBASE_1 <- function() {
  # Just adds "fixed = TRUE"
  do.call(rbind, lapply(peptides.vec, function(p) grepl(p, proteins.vec, fixed = TRUE)))
}

funBASE_2 <- function() {
  # Does away with the `do.call` but probably won't improve performance
  vapply(peptides.vec, function(x) grepl(x, proteins.vec, fixed = TRUE), logical(N))
}

library(stringi)
funSTRINGI <- function() {
  # Should be considerably faster
  vapply(peptides.vec, function(x) stri_detect_fixed(proteins.vec, x), logical(N))
}

library(microbenchmark)
microbenchmark(funOP(), funBASE_1(), funBASE_2(), funSTRINGI())
# Unit: milliseconds
#          expr        min         lq      mean     median         uq       max neval
#       funOP() 344.500600 348.562879 352.94847 351.585206 356.508197 371.99683   100
#   funBASE_1() 128.724523 129.763464 132.55028 132.198112 135.277821 139.65782   100
#   funBASE_2() 128.564914 129.831660 132.33836 131.607216 134.380077 140.46987   100
#  funSTRINGI()   8.629728   8.825296   9.22318   9.038496   9.444376  11.28491   100

请帮忙。

1 个答案:

答案 0 :(得分:0)

您可以通过以下方式使用Mul(Float('0.25', prec=15), Pow(sin(Mul(Float('0.33333333333333331', prec=15), Symbol('x'))), Integer(-1))) 功能:

substring()