There is an art to saying you're sorry and learning from your mistakes. And we all make mistakes and never stop learning.
A great deal of ancient Jewish writing focuses on this process, but you don't have to be Jewish to benefit from this hard-earned wisdom. In preparation for the journey of repentance from Rosh Hashanah to Yom Kippur, or whatever journey you are on, here is a modern paraphrase:
Before you say you're sorry, stop doing the bad behavior. Trying to apologize while still doing the wrong thing is like trying to bail water out of your basement without fixing the leak.
Apologize and mean it. Simple and direct is best. Apologize for the right thing, and wait until the other person can hear and accept your apology. Saying, "I'm sorry you're mad" or "I'm sorry you feel hurt" are not apologies. That's just saying, "Don't be mad at me" or "The problem is really you, not me." Be sincere. Say what you are sorry for and validate the feelings of the person you have wronged. And a public offense needs a public apology.
Make things right as best you can.
If you have sincerely apologized and done what you could to make things right but they refuse to forgive, apologize up to two more times. Remember recovery takes time, gentle persistence, and patience. But if they still refuse to forgive after three times, move on. The problem is now theirs, not yours. Being unforgiving is also no good.
Now the real work starts. Take time to reflect on what your sins really were. Let yourself feel regret, even shame or embarrassment. Rabbi Nachman of Breslov teaches the Hebrew letters of the word for repentance (teshuva) are the same as Shabbat. Make time and space for yourself to figure out why you behaved the way you did and how you can become a better person, the same way the Sabbath takes time out of the week. Where are you in your life? How did you get there? Take an inventory of your soul.
Confess to God. Pray out loud. It has to be out loud or else it is not real. The words have to leave your mouth and come back into your ear, or come out through your fingers in writing. Externalize it and give it up to God. Check your moral compass and return to God's path.
Resolve to never do it again. Tell another person you trust you won't do it again, and ask for their help. Use their assistance. Lean on them. You'll do the same for them, so it's okay.
Don't do it again. Moses Maimonides said, "The true repentant is the person who faces the same temptation again but doesn't sin."
Let it go. Forgive yourself. Love yourself, too.
Repeat for the rest of your life.