From: Danny Challis Date: 2010-06-25T02:03:52+09:00 Subject: Re: Count substrings in string, scan too slow I'm looking for non-overlapping matches (so a 2 in your example) I modified your code to do this for me like you showed and it works fine. I was thinking of trying a Boyer-Moore implementation, but I suspect if I implement this manually in Ruby it will be much slower. Jes炭s Gabriel y Gal叩n wrote: > On Thu, Jun 24, 2010 at 6:05 PM, Robert Klemme > wrote: >>>> s = "you like to play with your yo-yo" > > So, I don't know. Of course, if the requirement is to get 2 from the > above situation, adding the length is better. > > Also of notice is that the block versions of scan are slower because > they have to call a block for each match. > I think I've read that the String#index method uses Rabin-Karp. It > would be interesting to compare this to a Boyer-Moore implementation. > Of course it will depend on the input data, if it's near the best or > worst case for each, but anyway. > > Jesus. -- Posted via http://www.ruby-forum.com/.