templatization of regexes (and a few more)