I have a large (greater than 200K) array of Strings which I use to search for patterns in documents. I convert each entry in the array into a regular expression before I apply it to the document. When I do this, the amount of time it takes to go through the array and sequentially perform the search dramatically increases. I believe this is do to the Pattern.compile statement that I apply to each regular expression in turn before performing the search. Precompiling the regular expression may be a way around this but I've noticed a dramatic increase in memory usage when I do this. Before precompiling, the java application runs in a VM around 1.5 gigabytes in size. After precompiling, the java program runs in a VM around 14 gigs in size.
Is there some elegant way to get around this problem or to make the program run more efficiently?
Thank you,
Elliott