#!/usr/bin/env python
#coding: utf-8
'''
docstring for naive_string_matcher
diret tansalation from book "Introduction to Algorithms-CLRS"
@author: honghe
'''
def matcher(t, p):
'''
:param t: the string to check
:param p: pattern
'''
n = len(t)
m = len(p)
for s in xrange(0, n-m+1):
if p == t[s:s+m]:
print 'Pattern occurs with shift %d' % s
转载于:https://my.oschina.net/leopardsaga/blog/101421