Make the replace functions return the number of found matches