Our customers wish to use the / character in their templates. I also can't pass an escaped \/ to addTemplateVariable. It would seem more logical to escape the regex correctly within the PHPDOCX code like so:
function regexEscape($regex)
{
$patterns = array('/', '^', '.', '$', '|', '(', ')', '[', ']', '*', '+', '?', '{', '}', ',');
$replace = array('\/', '\^', '\.', '\$', '\|', '\(', '\)', '\[', '\]', '\*', '\+', '\?', '\{', '\}', '\,');
return str_replace($patterns, $replace, $regex);
}