Unicode regular expression engines are slow for large collections. However, hash-based set operations are much faster. This observation is based on an experiment with ICU's Regular Expressions package[15] and a hash-based set of the programming language F#.
First, I created a regular expression for the MULTILINGUAL EUROPEAN SUBSET 2
collection. After creating a matcher (an instance of the class RegexMatcher) from it, I
invoked it for the string " " 100000 times. In my computing environment (AMD
A10-7800, 16GB Memory, Windows 10), the elapsed time was about 0.4 seconds.
I then created a hash-based set for the same collection and tested if it contains the same string. I did this test 100000 times. The elapsed time was about 0.015 seconds. Thus, the hash-based set is more than 20 times faster than the ICU's Regular Expressions package.
Second, I did the same experiment for the IICORE
collection. In the case of the
regular expression matcher, the elapsed time was about 23 seconds. In the case of the
hash-based set, the elapsed time was about 0.015 seconds. Thus, the hash-based set is more
than 1600 times faster than the ICU's Regular Expressions package.
The slow performance of regular expression engines might not be problematic if the collection is not large. But it is fatal for huge CJK collections.