fixed a bug in r_str_replace