This describes me almost exactly when I was in my 20s. However, I have far fewer regrets than you might. My career progressed a lot faster than it otherwise would have, and thanks to salary compounding my family enjoys much greater financial security than we otherwise might have. The institutional and product knowledge I gained in those days enables me to now have a much more relaxed work schedule and spend time with my family while still delivering value. And finally, it’s fun to walk through a lab and see the software I wrote unprompted over a few weekends still humming along two decades later on hundreds of stations.
I am under no illusion that my company is my family, but I didn’t do it for them. I did it for myself, and the company happened to benefit. There have never been any loyalty expectations on either side, and I would probably do it all over again.