Python is not my best language, and so I\'m not all that good at finding the most efficient solutions to some of my problems. I have a very large string (coming from a 30 MB
You can use one of these algorithms:
Rabin–Karp string search algorithm
Knuth–Morris–Pratt algorithm (aka KMP) see an implementation here
Although I believe KMP is more efficient, it's more complicated to implement.The first link includes some pseudo-code that should make it very easy to implement in python.
you can look for alternatives here: http://en.wikipedia.org/wiki/String_searching_algorithm