Sayyiduna Abu Sa'id al-Khudri (may Allah be pleased with him) reports this saying of the Prophet (peace and blessings be upon him): "Whoever swears an oath and then sees something better than it, its expiation is that he abandons it."
Imam Ahmad recorded it, and its chain is hasan (good).