How to escape a string so it does not get replaced by Token::replace()
Token::replace() allows you to use a callback to replace extra tokens no module define, but that is called after the tokens have been replaced; plus, it gets a array as array($original_token =&gt; $replacement) which makes things slower since you would need to replace each token one by one.

I would rather set 'clear' to FALSE, and then replace all the tokens that have not been replaced with an empty string. Since the strings you need to keep follow a specific pattern, it would be easier to remove the unreplaced tokens with preg_replace().