The Messenger of Allah ﷺ said, "Whoever swears an oath and then sees that something else is better than it, let him make expiation for his oath and do what is better."
أن رسول الله ﷺ قال: من حلف بيمين، فرأى غيرها خيرا منها، فليكفر عن يمينه، وليفعل الذي هو خير.
Malik narrated it in Vows and Oaths (11) from Suhayl bin Abu Salih, from his father, from Abu Hurairah, and he mentioned it. Muslim narrated it in Oaths and Vows (12:1650) through the route of Malik, in like manner. There are other hadiths on this subject, and they are mentioned in the Book of Oaths.