Some of the ideas in thread 723032 may assist.
In reply to Re: efficient text processing by gone2015 in thread efficient text processing by sarutobi