.*?#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { foreach ($matches as $match) { $store[] = $match[0][0]; $_length = strlen($match[0][0]); $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; $source = substr_replace($source, $replace, $match[0][1] - $_offset, $_length); $_offset += $_length - strlen($replace); $_store++; } } // Strip all HTML-Comments // yes, even the ones in