My father got old, and had to downsize from a large house to a small flat, which didn't have room for all his books, so most of them went to charity shops. A year later, he advised me "Try not to get rid of your books; you'll regret it."
He's died now, I took over the flat, and moved from a family home into the same flat. I also had to shed a lot of books in the process. I ripped my large CD collection to a media server. I miss some of those books I got rid of; but I like this small flat, and I don't want to dedicate a small room to a library.
The first books I got rid of were computer books. They were all manuals for some obsolescent technology; like, I thought the "Rhino" Javascript book would be useful forever (um, no). I got rid of a few feet of books on Buddhism, and several more feet were books on Western philosophy from my undergraduate days. These were books that had been formative for me, but I was honestly never going to open them again.
So I don't really agree with my father's advice. If you regret ditching a book, you can just replace it.