in reply to Can you write a faster code to perform this task?

How complex does your pattern need to become? In the case of a pattern that consists of (M+), it's unnecessary to rev up the regexp engine.

General solutions work pretty well for the general case. Optimizations work by knowing more about the specific case, possibly allowing you to design the code with shortcuts, bypassing work that the general case might need, but that are unnecessary in the specific case. The more we know about the specifics, the better we can do at figuring out what shortcuts can be applied here.


Dave