in reply to Help with speeding up regex

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