I am trying to iteratively update the pattern I am looking for in a text.
- I know the length of the desired words; it is a constant, say 4
- I know the type of characters in the desired words; alphabetical, lowercase
- Unless I deliberately plug in a specific character in a particular index, the rest can be any letter (a-z, lowercase)
How can I go about changing the pattern iteratively?
For instance:
words <- c("bake", "tree", "keep", "game", "ride", "Bake", "Apple", "lame")
pattern1 <- '****'
# return "bake", "tree", "keep", "game", "ride", "lame"
pattern2 <- '*a**'
# return "bake", "game", "lame"
pattern3 <- '*a*e'
# return "bake", "game", "lame"
pattern4 <- '*ame'
# return "game", "lame"
Thank you!