It was narrated that Abu Hurayrah (may Allah be pleased with him) said: I heard the Prophet (peace and blessings of Allah be upon him) say: “A person committed a sin and said: ‘My Lord, I have sinned; forgive me.’ His Lord said: ‘Is My slave acknowledging that he has a Lord Who forgives sins and punishes for them? I have forgiven My slave.’ Then as much time passed as Allah willed, then he committed a sin and said, ‘My Lord, I have sinned; forgive me.’ His Lord said: ‘Is My slave acknowledging that he has a Lord Who forgives sins and punishes for them? I have forgiven My slave.’ Then as much time passed as Allah willed, then he committed a sin and said, ‘My Lord, I have sinned; forgive me.’ His Lord said: ‘Is My slave acknowledging that he has a Lord Who forgives sins and punishes for them? I have forgiven My slave,’ – three times…” [al-Bukhari, Muslim].
Al-Nawawi (may Allah have mercy on him) included this hadeeth (narration) under the heading: “Acceptance of repentance from sins even if the sins and repentance happen repeatedly.”
He said in his Sharh (commentary):
We have already discussed this issue at the beginning of the Book of Repentance.
*These hadeeths (narrations) clearly point to that, and even if the sin is repeated a hundred times or a thousand times or more, and he repents each time, his repentance will be accepted and his sin will be erased. And if he repents once from them all, his repentance will be valid.*
Sharh Muslim.