Sad indeed, but you can never turn back the time, but there is a way for you to change your future, avoid divorce and keep your marriage intact. Here is what you should do.
When you are caught cheating, the first thing that you should do is to apologize correctly. Many people know do apologize and know what it means, but few knows how to do it correctly. When you apologize, being sincere is not enough, you need to own it, and be responsible from your mistakes. This means that you should never ever blame your partner from your infidelity. Then, you should also include on how you make it right, and how to avoid making the same mistakes all over again.
Once you have the perfect apology, show in your actions that you are willing to accept the consequences of your actions and that you understand the pain that you have caused. Although you never will, but listening to your spouse and answering all the questions with all honesty is helpful. You know that there are so many limitations now, but you gladly accept it because you deserve it.
It is going to be hard work to keep your marriage after being caught cheating, but when you show commitment, you will get through.