Update the backup function for files. Add a new helper function for regex.