If you think Boyer-Moore is trippy, try to understand the partial match lookup table creation algorithm in Knuth-Morris-Pratt: http://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pr...
http://www.ics.uci.edu/~goodrich/dsa/11strings/demos/pattern...