Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/06/09 23:55
Read: times


 
#162160 - I recommend Boyer-Moore
Responding to: ???'s previous message
The slow method for matching a string with an input stream is to always step forward one step when failing a match. This is trivial code, and always works.

The stupid way, is to match as many characters as possible and on a failure throw away all history and continue from the current position. If the previous test fails after maching four characters, the position in the input stream is stepped four positions. This may be seen as an optimization since the amount of work is much less than the slow method, but instead it results in the problem Andy is seeing. However, this broken method is quite common. I don't know if it is very easy to be confused and think that is correct, but for some reason I have had the bad fortune to see it i more than one commercial sw package :(

The good way to do this (especially if you have room for a lookup table for each character in the alphabet) is to use the Boyer-Moore algorithm, where you do the matching starting from the last character in the pattern - if no match, then you can look up how many steps to step forward to get at least a partial align, instead of just stepping one step.

A good "graphical" presentation of the Boyer-Moore algorithm can be found here:

http://www.cs.utexas.edu/users/moo...ample.html


List of 15 messages in thread
TopicAuthorDate
OT: one for any AsyncPro experts...            01/01/70 00:00      
   Could this be it?            01/01/70 00:00      
      Looks like it            01/01/70 00:00      
         Do you know?            01/01/70 00:00      
            Just high probability            01/01/70 00:00      
   I use that            01/01/70 00:00      
      but...            01/01/70 00:00      
         Message ending            01/01/70 00:00      
            I think these are just workarounds            01/01/70 00:00      
               I recommend Boyer-Moore            01/01/70 00:00      
               Async            01/01/70 00:00      
                  Delphi            01/01/70 00:00      
                     Open source            01/01/70 00:00      
                  Test Case            01/01/70 00:00      
                     Away for a week            01/01/70 00:00      

Back to Subject List