Quantcast
Channel: MobileRead Forums
Viewing all articles
Browse latest Browse all 50094

Help: Regex Find & Replace Chapter Numbers In Words To Incremental Digits?

$
0
0
:help:

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

Viewing all articles
Browse latest Browse all 50094

Latest Images

Trending Articles



Latest Images