If the person was sorry because **only **he did not want to go to Hell and so was sorry out of fear, he would not be forgiven. This is called imperfect contrition. Imperfect contrition is when a person has sorrow for his sins only because he fears the consequences of them or because the sins are offensive to human sentiments. For instance, a person might feel terrible that he has committed adultery just because it is so disgusting a sin.
If the person was sorry because - while he may very well not want to go to Hell and fear this - he had offended God and this alone was enough to inspire sorrow, then he would be forgiven. This is called perfect contrition. Perfect contrition is when a person has sorrow for his sins because he has offended God. Other reasons for sorrow - fear or disgust, for instance - may be present as well in a perfectly contrite person, but the sorrow for having alone offended God would be present as well, whereas it would not in an imperfectly contrtite person.
A good way to judge this is to ask oneself whether or not he would be sorry for his sins if there were no punishment involved. If I knew that there was no punishment for this act but it offended God, would I be sorry for it then?
Of course, one must never take for granted the type of contrition he has, and ought always to get to confession as soon as possible after a mortal sin.