[R] gregexpr slow and increases exponentially with string length -- how to speed it up?

2008-10-30 Thread Emmanuel Levy
Dear All, I have a long string and need to search for regular expressions in there. However it becomes horribly slow as the string length increases. Below is an example: when i increases by 5, the time spent increases by more! (my string is 11,000,000 letters long!) I also noticed that - the

Re: [R] gregexpr slow and increases exponentially with string length -- how to speed it up?

2008-10-30 Thread Charles C. Berry
On Thu, 30 Oct 2008, Emmanuel Levy wrote: Dear All, I have a long string and need to search for regular expressions in there. However it becomes horribly slow as the string length increases. Below is an example: when i increases by 5, the time spent increases by more! (my string is 11,000,000

Re: [R] gregexpr slow and increases exponentially with string length -- how to speed it up?

2008-10-30 Thread Emmanuel Levy
Hi Chuck, Thanks a lot for your suggestion. You can find all such matches (not just the disjoint ones that gregexpr finds) using something like this: twomatch -function(x,y) intersect(x+1,y) match.list - list( which( vec %in% c(3,6,7) ),