http://www.perlmonks.org?node_id=89588


in reply to Unrolling the loop technique

Presumably, because they want to match the strings:

delimiter norma delimiter delimiter normallll special norma delimiter delimiter normall special normalllspecial norma delimiter delimiter normallllll special normal delimiter delimiter normal special normal delimiter

Without $1 being set to anything (that's what the "?:" after the opening bracket does).

Seriously, give us one or two of the actual regular expressions that are confusing you. The way you have it written, it's exactly equivalent to:

delimiter (?:special|normal)* delimiter

Assuming that each word is supposed to be a regex atom.

Update: Re-read the question :-} The reason why you'd want to do this would be if "special" is a pattern that matches the escaped delimiter and an escaped escape pattern, so that you can include the delimeters in the data.

Update: Someone just suggested that you'd want to unroll it for speed's sake... I recommend doing some speed profiling and seeing for yourself the kind of difference it makes... then deciding whether obfuscating your regular expressions is worth that speed increase. Hint: regular expressions are first compiled to an internal "deterministic acceptor", so it makes very little difference.