View Single Post
Old 10-07-2024, 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: 781
Karma: 1538394
Join Date: Sep 2013
Device: Kobo Sage
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; 10-07-2024 at 08:16 AM.
enuddleyarbl is offline   Reply With Quote