Suppose I have a character vector:
test <- c("a##", "b", "c##", "d", "e")
I want to retrieve the indexes of elements ending with "##".
How can I do that?
Here is one method using grep:
grep("##$", test)
This returns indices 1 and 3 as a vector. The "##$" is a regular expression that says match if ## are the last two characters, the "$". anchors the ## to the end.