I am pretty new to regular expressions in R and I am trying to match a vector of strings including some patterns and excluding some patterns. I searched on stackoverflow and it seems that no similar questions have been asked. Here is the vector of string
mystring to be matched.
mystring <- ("fhwjantdesd", "unwanted", "fdedsifrfed", "undesired", "sdsyessd", "yedsfd")
mystring I want to figure out if
mystring includes any permutation of 6 letters of “wanted” excluding the string “wanted”. Similarly, includes any permutation of the 7 letters of “desired” and 3 letters of “yes” excluding the string “desired” and “yes”.
So the expected output of
grepl(pattern, mystring, perl = TRUE) should be:
 TRUE, FALSE, TRUE, FALSE, FALSE, TRUE
I want to use the
perl option of grepl, which could speed up the function. Does anyone could provide some clues on this
pattern? And could you explain what does each part of the pattern means cos I am just a starter in using PCRE. Thanks