Mortal sins my be forgiven via the grace of perfect contrition:
1452 When it arises from a love by which God is loved above all else, contrition is called “perfect” (contrition of charity). Such contrition remits venial sins; it also obtains forgiveness of mortal sins if it includes the firm resolution to have recourse to sacramental confession as soon as possible.51
1453 The contrition called “imperfect” (or “attrition”) is also a gift of God, a prompting of the Holy Spirit. It is born of the consideration of sin’s ugliness or the fear of eternal damnation and the other penalties threatening the sinner (contrition of fear). Such a stirring of conscience can initiate an interior process which, under the prompting of grace, will be brought to completion by sacramental absolution. By itself however, imperfect contrition cannot obtain the forgiveness of grave sins, but it disposes one to obtain forgiveness in the sacrament of Penance.52
(note too that venial sins can be forgiven in many ways…though confession of course is wonderful and recommended as a frequent practice for such).
Of course even if one is believes they have perfect contrition - normally they need to wait for Holy Communion:
1385 To respond to this invitation we must prepare ourselves for so great and so holy a moment. St. Paul urges us to examine our conscience: "Whoever, therefore, eats the bread or drinks the cup of the Lord in an unworthy manner will be guilty of profaning the body and blood of the Lord. Let a man examine himself, and so eat of the bread and drink of the cup. For any one who eats and drinks without discerning the body eats and drinks judgment upon himself."218 Anyone conscious of a grave sin must receive the sacrament of Reconciliation before coming to communion.