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 10-06-2026, 01:32 PM   #1
Ilcaa
Junior Member
Ilcaa began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Dec 2011
Device: Nook
help with a Find regex

here is my html
Code:
<p class="c8">
    <span class="c3">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is .</span>
  </p>
my regex is
Code:
/<span[^>]*>(.*?)<\/span>/g

if i use a regex tester online it work, https://regex101.com/r/cqkkT1/1

I am trying to find the text within the span, i will eventually remove the span and place the text in the parent p-tag.

in calibre it doesnt find the text, "no matches were found". any help? thanks
Ilcaa is offline   Reply With Quote
Old 10-06-2026, 01:59 PM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 32,001
Karma: 65700000
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
K I S S
Use diaps toolbag plugin. It does proper matching of nested opening and closing tags
Preferences: Getplugins: Diaps Editing Toolbag
theducks is offline   Reply With Quote
Advert
Old 10-06-2026, 03:20 PM   #3
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,911
Karma: 9600930
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Ensure you have set the search Mode to Regex.

This might work better...

Find...
<p class="c8">\s+<span class="c3">(.*?)</span>\s+</p>

Replace...
<p class="c8">\1</p>

Assuming the classes are static.
Karellen is offline   Reply With Quote
Old 10-06-2026, 06:57 PM   #4
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 85,254
Karma: 154365101
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by theducks View Post
K I S S
Use diaps toolbag plugin. It does proper matching of nested opening and closing tags
Preferences: Getplugins: Diaps Editing Toolbag
Better to now use Otter's Editing Toolbag as it does the same thing and more. It's the new version.
JSWolf is online now   Reply With Quote
Old Yesterday, 12:52 PM   #5
lomkiri
Groupie
lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.
 
lomkiri's Avatar
 
Posts: 195
Karma: 1537710
Join Date: Jul 2021
Device: N/A
Quote:
Originally Posted by Ilcaa View Post
my regex is
Code:
/<span[^>]*>(.*?)<\/span>/g
The correct regex for calibre is :
Code:
<span[^>]*>(.*?)<\/span>
But it will rip out ALL the spans in your epub, you'll have to pass it in manual, or to be more specific about the class of the span (as Karellen emphasized)

The Theducks' suggestion to use the diaps toolbag plugin is excellent, it's very flexible and will take care of the embedded spans.

Quote:
Originally Posted by JSWolf View Post
Better to now use Otter's Editing Toolbag as it does the same thing and more. It's the new version.
To be noticed that this plugin is vibe-coded. The author is honest and advises in the 1st line of the post. But for my concern, I wont use LLM-generated code. I know this wave will submerge most of the beach, but the implications of those techniques are frightening enough (in various aspects : human, intellectual, social, ecological and educational, without speaking of the quality of the production) for me to avoid the most possible what LLMs have produced.

For the same reason (and to avoid to overshadow the contents of the web), I don't use google and Cie, not even bare ddg, but ddg with its noAI option : https://noai.duckduckgo.com

Last edited by lomkiri; Yesterday at 01:06 PM.
lomkiri is offline   Reply With Quote
Advert
Old Yesterday, 02:54 PM   #6
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 85,254
Karma: 154365101
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
If there a reason not to use Otter's Editing Toolbag just because it was created using AI? It does work.
JSWolf is online now   Reply With Quote
Old Yesterday, 03:37 PM   #7
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 32,001
Karma: 65700000
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by JSWolf View Post
If there a reason not to use Otter's Editing Toolbag just because it was created using AI? It does work.
Yes!
We recommended tools we had USED regularly for the task and our recommendations are still VALID.
theducks is offline   Reply With Quote
Old Yesterday, 04:58 PM   #8
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 54,940
Karma: 182340534
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by Ilcaa View Post
if i use a regex tester online it work, https://regex101.com/r/cqkkT1/1

I am trying to find the text within the span, i will eventually remove the span and place the text in the parent p-tag.

in calibre it doesnt find the text, "no matches were found". any help? thanks
When you tested using Regex101, which flavour of Regex did you test with? calibre uses the Python re and regex modules which Regex101 supports in it's flavour menu under Python. However the default flavour (for me at least) on Regex101 was PCRE2 (PHP) flavour which I kept since that is what Sigil uses. When I want to test for calibre, I change the flavour to Python.

Simpler regex searches will work under most implementations however even with those, you may find yourself being bitten on the butt.
DNSB is offline   Reply With Quote
Old Yesterday, 05:36 PM   #9
lomkiri
Groupie
lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.
 
lomkiri's Avatar
 
Posts: 195
Karma: 1537710
Join Date: Jul 2021
Device: N/A
Quote:
Originally Posted by theducks View Post
Yes!
We recommended tools we had USED regularly for the task and our recommendations are still VALID.
Exactly. Even putting apart all the very serious and crucial problems that LLMs are generating and that I summarily spoke about, there is the fundamental problem of the quality of the code.

Speaking of this precise case : Diap is a good and experienced dev, he knows what is doing –and why– when he writes a group of instructions. He knows which part of the text he will (or should) reach with the code. And afterwards, he knows where may be the flaws and which situations to test.

A machine doesn't think (the word AI is a lie, it's just a slogan for those things so people think it's magic, the real name is LLM, Large Language Model), it just makes hundreds of thousands iterations with all the code it has stolen in the internet (mainly in Github and Cie). We have no guaranty that the code is correct, even if it has been tested by humans.

An LLM-generated plugin may silently corrupt an epub, or may eat part of sentences or even some paragraphs without any warning, so in theory I should display and check all the changes, at each time I use it, which is not acceptable.

When you vibe-codes, you have no control over the code.

LLM may be used to create some small parts of simple code that the dev can understand and check and that he will integrate in hiis code. In other words, it may be used as an assistant for small parts of code. The dev is still the master of the code. Even if I'm not in favor of this use for ethical reasons.

LLM SHALL NOT be used to create entire softs or plugins, and even more if the author is not a dev.(I don't know if the creator of the Otter plugin is a dev or not). And mainly if there is a risk of data corruption during the use of this soft or plugin.

Last edited by lomkiri; Yesterday at 05:56 PM.
lomkiri is offline   Reply With Quote
Old Today, 11:15 AM   #10
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 85,254
Karma: 154365101
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
I've been using Otter's Editing Toolbag since it came out sometime in August. It works well.

If you don't use a plugin until it has been used, then you may as well never use any plugin because at some point, it's barely been used. That is a very silly argument not to use a plugin. Also, why say a plugin is no good when it work just because AI designed it? If the OP never said it was designed by AI, you'd never have known.
JSWolf is online now   Reply With Quote
Old Today, 12:16 PM   #11
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 32,001
Karma: 65700000
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by JSWolf View Post
I've been using Otter's Editing Toolbag since it came out sometime in August. It works well.

If you don't use a plugin until it has been used, then you may as well never use any plugin because at some point, it's barely been used. That is a very silly argument not to use a plugin. Also, why say a plugin is no good when it work just because AI designed it? If the OP never said it was designed by AI, you'd never have known.
I DON"T RECOMMEND things I have not given a shakedown when there ARE ones that have worked for the job requested.
theducks is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
New to regex find and replace! ksimpson1986 Sigil 2 11-06-2016 11:29 AM
regex cannot find to replace eschwartz Editor 11 02-03-2014 11:00 PM
Regex find and replace SanatyrZeo Sigil 5 10-29-2012 07:03 AM
RegEx find and replace iblesq Sigil 1 01-10-2011 09:26 PM
REGEX find and replace help please potestus Sigil 13 09-18-2010 04:14 PM


All times are GMT -4. The time now is 02:16 PM.


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