The Messenger of Allah ﷺ said, "When one of you swears an oath and then sees that something else is better than it, let him make expiation for his oath and pursue what is better."
أخبرنا محمد بن عبد الأعلى قال حدثنا المعتمر عن أبيه عن الحسن
عن رسول الله ﷺ قال إذا حلف أحدكم على يمين فرأى غيرها خيرا منها فليكفر عن يمينه ولينظر الذي هو خير فليأته
Recorded by Muslim, Oaths, Chapter on the encouragement to break an oath and do what is better when one sees something better than it, etc., hadith no. 1652, from the narration of Mutamir bin Sulayman. Also by Bukhari, Oaths and Vows, Chapter on the saying of Allah Almighty, "Allah will not call you to account for thoughtless words in your oaths" [Baqarah 2:225], hadith no. 6622, from the narration of Hasan Basri, with the same wording. It is also found in Al-Kubra, hadith no. 4724.