in reply to Re^2: regex matching using arrays
in thread regex matching using arrays

Do you know if there is a limit on the size that $regex can take? i.e. if the array is really big will it break things?
If you have a large word list, and you're trying to determine which of those words occur in a given text of arbitrary length, the best approach is likely to be to store the word list in a hash, then tokenize the text string; for each tokenized word in the string, if that word exists as a hash key, you've got a hit (append that word to your output list).

This way, you've got one simple loop over the "lexicon" (to store the word list as hash keys), and one loop over the word tokens in the text string; you're doing plain string comparisons (best to put everything in monocase) instead of regex matches, so it should be pretty quick.