Try this:
set.seed(1234)
xstr <- replicate(100, paste(sample(letters), collapse = ''))
patt <- c('dmu', 'kpz', 'ajt')
sapply(patt, gregexpr, text = xstr)
On Wed, Oct 27, 2010 at 5:53 AM, makhdoomi <abraufshah@gmail.com> wrote:
> Dear all,
>
> how can i search multiple text or string patterns in a text file.
> i have written the following script but it is for only single searches at a
> time.
> how can i get multiple searches e.g
> "xyz","abc","pqr".....at a time and can save
the results to an out file.
>
> script::
> x<- "abc"
> z<-NULL;for (i in 1:1235){{if
> (as.integer(regexpr(pattern=x,as.character(abstracts_abc[i,2]),
> ignore.case=TRUE)) != 1) z<- c(z, i) }}
> temp<- z[1]; testfile<- abstracts_abc[temp,]
> for (i in 2:250){temp<- z[i]; testfile<-
> rbind(testfile,abstracts_abc[temp,])}
>
> Kind regards
> Ab Rauf Shah
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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.
>
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
[[alternative HTML version deleted]]