Aside from building one combined regex by using Regexp::Assemble, it comes down to a tradeoff between doing multiple substr() queries against the string and running one regex against the string. If you care, the development version of Perl, "bleadperl", has an improvements regex engine by demerphq which make such searching faster.
The only optimization besides using a different version of Perl that could make your regex faster would be to collect all the first letters of all your words and make them into a zero-width lookahead character class I think, but I would make sure by benchmarking that this really brings a speedup.
In reply to Re: Fast searching of multiple substrings in a string
by Corion
in thread Fast searching of multiple substrings in a string
by dgaramond2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |