content[na.omit(pmatch(searchset, content,,TRUE))]
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Ralf B
> Sent: Tuesday, July 13, 2010 5:47 AM
> To: r-help at r-project.org
> Subject: [R] StartsWith over vector of Strings?
>
> 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")
>
> Best,
> Ralf
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.