Make sure value in regex_replace is a string

Fixes #7551