Take the 2-minute tour ×

I have a fixed string S of size n on which I make a lot of substring queries. One way to optimise for this situation is to preprocess the string and build a suffix tree, or suffix array. After preprocessing, substring queries can be performed optimally on S.

Is there an easy way, in Python, to preprocess strings "out of the box", without having to manually write all the code to build a suffix tree or suffix array?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

I believe that the emsre python package provides exactly what you are looking for.

share|improve this answer
Thanks, although I cannot use external packages... –  Randomblue Feb 21 '12 at 1:12
@Randomblue: why not? –  DSM Feb 21 '12 at 1:46
I'm playing around at interviewstreet.com –  Randomblue Feb 21 '12 at 1:57

Your Answer


