Allow greater control over template regex matching.

Fixes 38