Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old Today, 09:59 AM   #1
lindlind
Junior Member
lindlind began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Mar 2024
Device: none
Replace group in Regex function mode

I have the following string:

Code:
<span class="line">Come here, he says.<span aria-label="11" class="page-normal" id="d5e1496" role="doc-pagebreak" title="11" epub:type="pagebreak"></span></span><br />
If I do a search and replace in Regex mode like this:

Search:
Code:
<span([^>]*"pagebreak"> ?)</span>
Replace:
Code:
<xxspan\1</xxspan>
The result is:

Code:
<span class="line">Come here, he says.<xxspan aria-label="11" class="page-normal" id="d5e1496" role="doc-pagebreak" title="11" epub:type="pagebreak"></xxspan></span><br />

However, if I add the following in a Regex-function:

Code:
return regex.sub('<span([^>]*"pagebreak"> ?)</span>', '<xxspan\1</xxspan>', match.group())
The result is this:

Code:
<span class="line">Come here, he says.<xxspan</xxspan></span><br />
What am I doing wrong here?
lindlind is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to replace text with Search and Replace with regex on Calibre darrnih ePub 2 04-02-2024 02:10 AM
Regex in Regex function mode lindlind Editor 5 03-22-2024 03:41 AM
[Plugin] regex function replace plugin The_book Plugins 19 09-23-2022 07:58 AM
Can we run Function mode in Search & replace during the conversion process? omin Conversion 2 02-08-2020 08:53 PM
Missing "function mode" for editor's Search & Replace atux Editor 3 01-17-2016 08:40 AM


All times are GMT -4. The time now is 12:14 PM.


MobileRead.com is a privately owned, operated and funded community.