How to deal with the end

w

Why is it so hard to let go of someone who treated me so poorly? Literally one of the last things he said to me before cutting contact was that I’m trash. Yet it’s so hard to keep thinking about how he’s gone from my life forever; I keep thinking about wanting the last 3 years back even though the relationship was flawed and I know I don’t have a real future with him. I have nightmares every night haunting me and telling me I should try to contact him. How can I just forget him? How long is it going to take?