Sorry, but nobody "manually" made ids like that. Those were automatically generated by a program of some sort. You can change them to anything you like. Unfortunately, changing them WILL be a manual process. And if the book has lots and lots of links, it may also prove painful.
No regex is gong to do what you want. You'd likely have to write a parsing algorithm that is capable of examining the current id and matching it with url fragments throughout the book so it could change them all to match. It would also need to maintain a list of all id's currently in use to ensure that your short, yet random id generator (which will need to be taught to create valid ids) creates ids that are guaranteed to be unique for that file. Your algorithm could also just create ids that started with a letter and added an auto-incrementing number (but would still need to parse the rest of the book to adjust all links as it went).
Whether you do it manually, or you write a program/script to do it for you. there's nothing but hard work and time ahead of you.