replace all equal expressions in brackets with one answer