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 Yesterday, 06:14 AM   #1
Blaineoreski
Zealot
Blaineoreski exercises by bench pressing the entire Harry Potter series in hardcoverBlaineoreski exercises by bench pressing the entire Harry Potter series in hardcoverBlaineoreski exercises by bench pressing the entire Harry Potter series in hardcoverBlaineoreski exercises by bench pressing the entire Harry Potter series in hardcoverBlaineoreski exercises by bench pressing the entire Harry Potter series in hardcoverBlaineoreski exercises by bench pressing the entire Harry Potter series in hardcoverBlaineoreski exercises by bench pressing the entire Harry Potter series in hardcoverBlaineoreski exercises by bench pressing the entire Harry Potter series in hardcoverBlaineoreski exercises by bench pressing the entire Harry Potter series in hardcoverBlaineoreski exercises by bench pressing the entire Harry Potter series in hardcoverBlaineoreski exercises by bench pressing the entire Harry Potter series in hardcover
 
Blaineoreski's Avatar
 
Posts: 113
Karma: 16268
Join Date: Apr 2020
Device: none
Question Can't Search and replace Regex

Hi,

Using Calibre's Editor I can see the following code:

<p class="noindent"><span class="txbdit">SOME TEXT</span>

I want to change all instances to h4

<h4>SOME TEXT</h4>

I've used

Mode: Regex Wrap checked, Dot all, checked

It keeps saying, "0 Replacements"

I've tried the following syntaxes:

<p class="noindent"><span class="txbdit">(.*?)</span>

<h4>$1</h4>


<p class="noindent"><span class="txbdit">.*?</span>

<h4>$1</h4>


AS WELL AS
<p\s+class="noindent"><span\s+class="txbdit">.*? </span>

<p\s*class="noindent"\s*><span\s*class="txbdit"\s* >.*?</span>


INTERESTINGLY
I cannot search or replace even

<p>
<h4>

But, searching and replacing for

<p class="noindent">
Pericles

Works.

What do you think is happening?

https://ibb.co/Lkj9KKN
Blaineoreski is offline   Reply With Quote
Old Yesterday, 07:12 AM   #2
enuddleyarbl
Guru
enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.
 
enuddleyarbl's Avatar
 
Posts: 746
Karma: 1077122
Join Date: Sep 2013
Device: Kobo Forma
To me, the error implies a problem with the Search phrase. But, the thing that hits me is in the replacement string. Instead of:
Code:
<h4>$1</h4>
use:
Code:
<h4>\1</h4>
Calibre's Editor (which uses the Python flavor or regex) uses \ instead of $ for replacement groups.

EDIT: In the Search phrase, I'd also try .+? instead of .*?. According to:

https://regex101.com/

.*? means:

"1st Capturing Group (.*?)
. matches any character (except for line terminators)
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)"

and

.+? means

"1st Capturing Group (.+?)
. matches any character (except for line terminators)
+? matches the previous token between one and unlimited times, as few times as possible, expanding as needed (lazy)"

The difference being the lower number of matches (0 vs 1).

Last edited by enuddleyarbl; Yesterday at 08:16 AM.
enuddleyarbl is offline   Reply With Quote
Advert
Old Today, 12:51 AM   #3
Blaineoreski
Zealot
Blaineoreski exercises by bench pressing the entire Harry Potter series in hardcoverBlaineoreski exercises by bench pressing the entire Harry Potter series in hardcoverBlaineoreski exercises by bench pressing the entire Harry Potter series in hardcoverBlaineoreski exercises by bench pressing the entire Harry Potter series in hardcoverBlaineoreski exercises by bench pressing the entire Harry Potter series in hardcoverBlaineoreski exercises by bench pressing the entire Harry Potter series in hardcoverBlaineoreski exercises by bench pressing the entire Harry Potter series in hardcoverBlaineoreski exercises by bench pressing the entire Harry Potter series in hardcoverBlaineoreski exercises by bench pressing the entire Harry Potter series in hardcoverBlaineoreski exercises by bench pressing the entire Harry Potter series in hardcoverBlaineoreski exercises by bench pressing the entire Harry Potter series in hardcover
 
Blaineoreski's Avatar
 
Posts: 113
Karma: 16268
Join Date: Apr 2020
Device: none
Boom! Perfect! Worked like a CHARM! Can't thank you enough. ))!!!!!!!!!!!!

Blaineoreski 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 search and replace yamusing Library Management 12 05-07-2020 01:19 PM
Regex in search problems (NOT Search&Replace; the search bar) lairdb Calibre 3 03-15-2017 07:10 PM
Regex search and replace dwlamb Sigil 6 04-12-2013 02:34 PM
regex search/replace Sharlene Sigil 10 01-28-2012 04:14 AM


All times are GMT -4. The time now is 08:14 AM.


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