Adds code to build optimized regexes from arrays of strings
Adds code to build optimized regexes from arrays of strings

The build_regex() creates optimized regular expressions from an array of strings.

An optimized regex built using this function will be much faster than a simple regex built using `implode('|', $strings)` --- anywhere from several times to several orders of magnitude faster.

However, the time required to build the optimized regex is approximately equal to the time it takes to execute the simple regex. Therefore, it is only worth calling this function if the resulting regex will be used more than once.

Because PHP places an upper limit on the allowed length of a regex, very large arrays may be split and returned as multiple regexes. In such cases, you will need to iterate through all elements of the returned array in order to test all possible matches.

Signed-off-by: Jon Stovell <5fe09b7d9f00fd95250ae2a73993b352b084988d@gmail.com>

StealthWombat/SMF2.1-more-forkery,StealthWombat/SMF2.1-more-forkery