1
「el」という文字列を検出するための正規表現を書いています(「除外」の略でフォーマットの悪いスコアデータの中にあります)。文字列を非アルファベット文字(または何もない)で区切って検出する正規表現
tests <- c("el", "hello", "123el", "el/27")
例えば
ここで私は結果TRUE, FALSE, TRUE, TRUE
を探しています。
library(stringr)
str_detect(tests, "el") # TRUE TRUE TRUE TRUE
str_detect(tests, "[^a-z]el") # FALSE FALSE TRUE FALSE
私はあなたの操作が何を望んでいるかに応じてより安全だと思っています。たとえば、 'grepl("(\\ b | [^ [:alpha:]])el(\\ b | [^ [: 、 "123el27") 'と!grepl(" \\ wel \\ w "、" 123el27 ")'異なる結果を返す – rawr