An Act of Contrition is the prayer of sorrow for sin, said in confession and whenever you turn back to God. The Church asks for the act, not a fixed set of words.

The prayer
Act of Contrition
O my God, I am heartily sorry for having offended thee, and I detest all my sins because of thy just punishments, but most of all because they offend thee, my God, who art all good and deserving of all my love. I firmly resolve, with the help of thy grace, to sin no more and to avoid the near occasions of sin. Amen.
How to pray it
The heart of the prayer is the second reason: not fear of punishment, but that sin offends the God who is all good. Say that line slowly, and mean the resolution at the end.
Where it comes from
Contrition is "sorrow of the soul and detestation for the sin committed, together with the resolution not to sin again" CCC 1451 (tier 1 citation). It is the first act the penitent makes in the sacrament of reconciliation.