chr.vector <- c("James", "Mary", "Michael", "Patricia", "Robert", "Jennifer")
# Example 1: Indices of matching elements
chr.grep(c("am", "er"), chr.vector)
# Example 2: Values of matching elements
chr.grep(c("am", "er"), chr.vector, value = TRUE)
# Example 3: Matching element?
chr.grepl(c("am", "er"), chr.vector)
Run the code above in your browser using DataLab