Skip to content

pattern search

2 messages · Sean Liang, Uwe Ligges

#
hi, I like to find a pattern within a giver sequence. There might be
multiple occurences of the pattern. I like to know the number of
occurences and the positions if possible. "grep" can tell me if a
pattern exists but can't give me the information I need. Does anyone
know any function that I can use or know how to do what I intend?.
Thanks a lot.

Sean
#
Sean Liang wrote:

            
???

   gr <- grep("a", c("a", "b", "a"))

grep tells you that the positions are 1 and 3. length(gr) tells you 
there are two occurences.

Uwe Ligges