[R] StartsWith over vector of Strings?

Ralf B ralf.bierig at gmail.com
Tue Jul 13 13:46:33 CEST 2010

Given vectors of strings of arbitrary length

content <- c("abc", "def")
searchset <- c("a", "abc", "abcdef", "d", "def", "defghi")

Is it possible to determine the content String set that matches the
searchset in the sense of 'startswith' ? This would be a vector of all
strings in content that start with the string of any of the strings in
the searchset. In the little example here, this would be:

result <- c("abc", "abc", "def", "def")


More information about the R-help mailing list