The perl script shared by St_Albert on page 1 in post #3, filters an EPUB's .ncx file to generate html code for an internal TOC.
The script inspired me to find out if this could also be done using regex+replace. The answer seems to be yes, as described in EPUB forum thread
https://www.mobileread.com/forums/sho....php?p=1446702
(If you have any comments/replies to this regex approach, please post them in the EPUB thread.)