Safe replace string extension