All of those alternations are possibly causing the regex engine to do a lot of extra work due to backtracking.
Consider changing the parts of your regexp that look like
(?:a|b|c)
to use independent subexpressions like
(?>a|b|c)
This is documented in perlre - Extended Patterns (look for (?>pattern) - it's a fair way down that section).
You may also find Regexp::Debugger to be a useful tool for visualising what the regex engine is doing.
-- Ken
In reply to Re: Help with speeding up regex
by kcott
in thread Help with speeding up regex
by eversuhoshin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |