Only run stringreplace if we need to.

Closes #8482