View Single Post
Old 06-16-2024, 06:36 AM   #1
Bozana
Bozana
Bozana does all things with Zen-like beautyBozana does all things with Zen-like beautyBozana does all things with Zen-like beautyBozana does all things with Zen-like beautyBozana does all things with Zen-like beautyBozana does all things with Zen-like beautyBozana does all things with Zen-like beautyBozana does all things with Zen-like beautyBozana does all things with Zen-like beautyBozana does all things with Zen-like beautyBozana does all things with Zen-like beauty
 
Bozana's Avatar
 
Posts: 25
Karma: 32224
Join Date: Jan 2013
Device: PC
Thumbs down Help: Regex Find & Replace Chapter Numbers In Words To Incremental Digits?



I have a book that needs to replace all the chapter headings in h2 that are in words to digits/integers and increment them. I'm using Calibre Editor but happy to jump over to sigil too, to get this Epub sorted.

Example:

<h2 class="heading_sed1">

<p class="class_sex">Chapter</p>

<p class="class_sez">Eighty-One</p>

</h2>

To

<h2 class="class_sex">Chapter 81</h2>


So far, I have the search part correct with either versions:

(?s)(<h2[^<>]*>)(.+?</h2>)


Or

<h2 class="heading_sed1">

<p class="class_sex">Chapter</p>

<p class="class_sez">[a-zA-Z0-9]+</p>

</h2>


However, it's my regex replace that's giving me trouble:

<h2 class="class_sez">Chapter \i+</h2>


Is there a way to accomplish this, without manually renaming them all?

And this book has part 1 and part 2 and the increments has to start over again in part two, in the same book.

I'm grateful for any help.

Thank you!

Kindest regards,

Bozana

Last edited by Bozana; 06-16-2024 at 07:11 AM.
Bozana is offline   Reply With Quote