First of all, thank you everyone for your help, I feel like I'll never learn how to properly use regex without a starting expression to edit, it's too broad and confusing for me
I found it odd that there wasn't a thread already of someone with this problem, so I'm trying to be detailed in case someone needs this in the future.
In the end I took the first idea by Davidfor and modified it a bit to keep as much of the original tagging as possible. Here's the string I used to find (I added the part to detect the
ids of the tags):
Code:
<h2 id="sigil_toc_id_\d{1,2}">(.*?)</h2>\s*<h3 id="sigil_toc_id_\d{1,2}">(.*?)</h3>
And here's the string to replace with:
Code:
<h2 class="hidden">\1 \2</h2><h2 class="ChapterTitle">\1</h2><h3 class="ChapterSubtitle">\2</h3>
After this I used the ToC generation tool for multilevel elements with XPath:
- h1 for the first level
- h2 with class=hidden for the second level
and it worked like a charm!