Sayyiduna Mu'awiyah bin al-Hakam al-Sulami (may Allah be pleased with him) narrated: I said: "O Messenger of Allah! I am a man who swears oaths about things and then regrets them." The Prophet (peace and blessings be upon him) said: "Whoever swears an oath and then considers something else better than it, let him do what is better and give expiation for his oath."
Imam al-Tabarani recorded it in al-Mu'jam al-Awsat; its chain contains a narrator whom I do not know.