If you want all the matches (including overlaps) then you could try one of these:
> gregexpr("(?=abab)","ababab",perl=TRUE) [[1]] [1] 1 3 attr(,"match.length") [1] 0 0 > gregexpr("ab(?=ab)","ababab",perl=TRUE) [[1]] [1] 1 3 attr(,"match.length") [1] 2 2 The book "Mastering Regular Expressions" by Jeffrey Friedl has a lot of detail on the hows and whys of regular expression matching. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > [EMAIL PROTECTED] > Sent: Wednesday, October 10, 2007 8:36 AM > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Subject: [Rd] gregexpr (PR#9965) > > Full_Name: Peter Dolan > Version: 2.5.1 > OS: Windows > Submission from: (NULL) (128.193.227.43) > > > gregexpr does not find all matching substrings if the > substrings overlap: > > > gregexpr("abab","ababab") > [[1]] > [1] 1 > attr(,"match.length") > [1] 4 > > It does work correctly in Version 2.3.1 under linux. > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel