Evaluate content before passing to regex.sub

Closes #1708