[功败垂成 / 功敗垂成, gōng bài chuí chéng, ㄍㄨㄥ ㄅㄞˋ ㄔㄨㄟˊ ㄔㄥˊ]to fail within sight of success (成语 saw); last-minute failure; to fall at the last hurdle; snatching defeat from the jaws of victory#61795[Add to Longdo]
[转败为胜 / 轉敗為勝, zhuàn bài wéi shèng, ㄓㄨㄢˋ ㄅㄞˋ ㄨㄟˊ ㄕㄥˋ]to turn defeat into victory (成语 saw); snatching victory from the jaws of defeat#112878[Add to Longdo]