Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 09-25-2026, 03:19 PM   #1
Siavahda
Addict
Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.
 
Posts: 287
Karma: 9400
Join Date: Aug 2010
Location: Helsinki
Device: Kobo Clara Colour
Regex search and replace

Trying to find (and get rid of) all instances of this

Code:
<div class="mbp_pagebreak" id="calibre_pb_0">
but my go-to, which would be <div class="mbp_pagebreak" id=".*?">, isn't working.

I have no idea how regex search works or anything, I've just been following instructions I've been given before.

What do I need to search to be finding this bit of code?
Siavahda is offline   Reply With Quote
Old 09-25-2026, 03:28 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: 31,976
Karma: 65700000
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
What is the range (next to the Mode 'regex') you set?
All text files
BTW I use a less wild term
Code:
<div class="mbp_pagebreak" id="calibre_pb_\d+">
The \d+ say only numbers in that position
theducks is offline   Reply With Quote
Advert
Old 09-25-2026, 04:24 PM   #3
gbm
Wizard
gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.
 
Posts: 2,299
Karma: 8891824
Join Date: Jun 2010
Device: Kobo Clara HD,Hisence Sero 7 Pro RIP, Nook STR, jetbook lite
The easy and fastest way is to use Diaps Editing Toolbag plugin for the editor.
Click image for larger version

Name:	Screenshot from 2026-09-25 16-20-42.png
Views:	25
Size:	54.2 KB
ID:	226237

bernie

Quote:
Originally Posted by Siavahda View Post
Trying to find (and get rid of) all instances of this

Code:
<div class="mbp_pagebreak" id="calibre_pb_0">
but my go-to, which would be <div class="mbp_pagebreak" id=".*?">, isn't working.

I have no idea how regex search works or anything, I've just been following instructions I've been given before.

What do I need to search to be finding this bit of code?
gbm is offline   Reply With Quote
Old Yesterday, 04:02 AM   #4
Siavahda
Addict
Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.
 
Posts: 287
Karma: 9400
Join Date: Aug 2010
Location: Helsinki
Device: Kobo Clara Colour
Quote:
Originally Posted by theducks View Post
What is the range (next to the Mode 'regex') you set?
All text files
BTW I use a less wild term
Code:
<div class="mbp_pagebreak" id="calibre_pb_\d+">
The \d+ say only numbers in that position
Thank you, this worked perfectly!

The settings I was using were Mode: regex, all text files, Down, Wrap. (I'm not sure I understand the question so I hope that's what you were asking?)
Siavahda is offline   Reply With Quote
Old Yesterday, 04:07 AM   #5
Siavahda
Addict
Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.
 
Posts: 287
Karma: 9400
Join Date: Aug 2010
Location: Helsinki
Device: Kobo Clara Colour
Quote:
Originally Posted by gbm View Post
The easy and fastest way is to use Diaps Editing Toolbag plugin for the editor.
Attachment 226237

bernie
This looks fantastic, but I think I'm missing something - when I use it, it only affects the file I have open right then, not the whole book at once?

Last edited by Siavahda; Yesterday at 04:09 AM.
Siavahda is offline   Reply With Quote
Advert
Old Yesterday, 06:32 AM   #6
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: 31,976
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 Siavahda View Post
This looks fantastic, but I think I'm missing something - when I use it, it only affects the file I have open right then, not the whole book at once?
There is a 'tick box' setting on the icon ( click the arrow). Yours must currently be ticked: current file only
theducks is offline   Reply With Quote
Old Yesterday, 07:57 AM   #7
maddz
Wizard
maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.
 
Posts: 1,643
Karma: 30496938
Join Date: Mar 2010
Location: UK
Device: Kobo Forma, Icarus, iPad Mini 2, Kobo Touch, Google Nexus 7
Out of curiosity, does Diap's plug-in deal with indented CSS files? I'm engaged in cleaning up my library using Edit Books, and the biggest issue I've found is missing font-family fallbacks. There's one book with over 2500... (It's a graphic novel which I don't send to my Kobo, but I'd like to clean it anyway.)

Unfortunately, because of the indents, search and replace or regex searches don't find them.
maddz is offline   Reply With Quote
Old Yesterday, 08:21 AM   #8
Lukusaukko
Connoisseur
Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.
 
Posts: 82
Karma: 392326
Join Date: Feb 2023
Device: Kobo Libra 2
Quote:
Originally Posted by maddz View Post
Unfortunately, because of the indents, search and replace or regex searches don't find them.
Diaps has very limited CSS tools. There's a new plugin that I've made Otter's Editing Toolbag that has functions to remove font face rules (though it's been made with AI assistance, and some people are against that).

OTOH, there's basically no reason why regexp couldn't find indented lines - hard to say what would be the issue without seeing the stylesheet, but something like ^\s+@ would match any number of spaces from line start to @ - thought the challenge might be to find a regexp that doesn't overmatch.
Lukusaukko is offline   Reply With Quote
Old Yesterday, 08:31 AM   #9
Siavahda
Addict
Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.
 
Posts: 287
Karma: 9400
Join Date: Aug 2010
Location: Helsinki
Device: Kobo Clara Colour
Quote:
Originally Posted by theducks View Post
There is a 'tick box' setting on the icon ( click the arrow). Yours must currently be ticked: current file only
There isn't an arrow?

If I go to the plugin menu in the editor, I have

Convert CSS cm to em
Edit Span & Divs
Run Epubcheck
Smarten punctuation (the sequel)

The convert css one and the smarten punctuation one both have arrows, with a tick box. But the Edit Span & Divs one doesn't?
Siavahda is offline   Reply With Quote
Old Yesterday, 08:40 AM   #10
maddz
Wizard
maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.
 
Posts: 1,643
Karma: 30496938
Join Date: Mar 2010
Location: UK
Device: Kobo Forma, Icarus, iPad Mini 2, Kobo Touch, Google Nexus 7
Quote:
Originally Posted by Lukusaukko View Post
OTOH, there's basically no reason why regexp couldn't find indented lines - hard to say what would be the issue without seeing the stylesheet, but something like ^\s+@ would match any number of spaces from line start to @ - thought the challenge might be to find a regexp that doesn't overmatch.
It looks like either spaces or tabs when you open the CSS in the editor. Copying the whole line has whitespace then the expression and hitting find returns nothing. Deleting the leading whitespace so you're left with just the expression also finds nothing...

I was wondering because it's seriously tedious clearing these missing CSS font fallbacks; being able to search and replace would simplify the task enormously. (Mind you, I'm still on calibre 7.26.) I don't mind doing a search and replace for each font value, what's tedious is manually replacing dozens of the same value.
maddz is offline   Reply With Quote
Old Yesterday, 09:12 AM   #11
maddz
Wizard
maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.
 
Posts: 1,643
Karma: 30496938
Join Date: Mar 2010
Location: UK
Device: Kobo Forma, Icarus, iPad Mini 2, Kobo Touch, Google Nexus 7
Checked in Pages with 'show invisible' and the whitespace is 4 spaces:

.calibre7 {
display: block;
font-family: "Times New Roman", serif;
text-align: justify;
text-indent: 2em;
margin: 0
}

But any search for the block or the specific expression isn't finding anything.
maddz is offline   Reply With Quote
Old Yesterday, 09:36 AM   #12
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: 31,976
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 maddz View Post
Out of curiosity, does Diap's plug-in deal with indented CSS files? I'm engaged in cleaning up my library using Edit Books, and the biggest issue I've found is missing font-family fallbacks. There's one book with over 2500... (It's a graphic novel which I don't send to my Kobo, but I'd like to clean it anyway.)

Unfortunately, because of the indents, search and replace or regex searches don't find them.
Beautify the CSS first, that makes is normal throughout. S&R then works a lot better.
FWIW I don't worry about a fallback font on books for my use if the font is embedded or already on my device.
theducks is offline   Reply With Quote
Old Yesterday, 09:42 AM   #13
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: 31,976
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 Siavahda View Post
There isn't an arrow?

If I go to the plugin menu in the editor, I have

Convert CSS cm to em
Edit Span & Divs
Run Epubcheck
Smarten punctuation (the sequel)

The convert css one and the smarten punctuation one both have arrows, with a tick box. But the Edit Span & Divs one doesn't?
That is interesting:
I had placed the Toolbag icon on the Toolbar (Preferences IN the Editor)and it has the arrow, where the Plugins menu does not offer the option
theducks is offline   Reply With Quote
Old Yesterday, 10:21 AM   #14
Lukusaukko
Connoisseur
Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.Lukusaukko ought to be getting tired of karma fortunes by now.
 
Posts: 82
Karma: 392326
Join Date: Feb 2023
Device: Kobo Libra 2
Quote:
Originally Posted by maddz View Post
Checked in Pages with 'show invisible' and the whitespace is 4 spaces:

.calibre7 {
display: block;
font-family: "Times New Roman", serif;
text-align: justify;
text-indent: 2em;
margin: 0
}

But any search for the block or the specific expression isn't finding anything.
This regexp should do it "\.calibre7\s{.+?}" - find literal period, then calibre7 followed by space and curly bracket, then match everything until next closing curly bracket. If you want to include the whitespace, you could try "^\s+\.calibre7\s{.+?}" which should match any number of whitespace from start of the line until literal period followed by calibre7 etc. With Dot all checked. This is on Calibre 9, mind, so it's possible that Calibre 7 has a different regexp engine that doesn't work quite the same way.

Last edited by Lukusaukko; Yesterday at 10:40 AM.
Lukusaukko is offline   Reply With Quote
Old Yesterday, 11:16 AM   #15
maddz
Wizard
maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.maddz ought to be getting tired of karma fortunes by now.
 
Posts: 1,643
Karma: 30496938
Join Date: Mar 2010
Location: UK
Device: Kobo Forma, Icarus, iPad Mini 2, Kobo Touch, Google Nexus 7
Quote:
Originally Posted by Lukusaukko View Post
This regexp should do it "\.calibre7\s{.+?}" - find literal period, then calibre7 followed by space and curly bracket, then match everything until next closing curly bracket. If you want to include the whitespace, you could try "^\s+\.calibre7\s{.+?}" which should match any number of whitespace from start of the line until literal period followed by calibre7 etc. With Dot all checked. This is on Calibre 9, mind, so it's possible that Calibre 7 has a different regexp engine that doesn't work quite the same way.
Another reason to go to calibre 9, then, but we have 3 installations that need updating (not counting the 32-bit installs which I no longer use...)

But I'll give theducks beautifying suggestion a try first.
maddz is offline   Reply With Quote
Reply

Tags
regex

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search and Replace with Regex Wiggo Library Management 9 09-29-2024 07:51 AM
how to replace text with Search and Replace with regex on Calibre darrnih ePub 2 04-02-2024 02:10 AM
Regex in search problems (NOT Search&Replace; the search bar) lairdb Calibre 3 03-15-2017 07:10 PM
regex search/replace Sharlene Sigil 10 01-28-2012 04:14 AM
need regex help search and replace schuster Calibre 4 01-10-2011 09:00 AM


All times are GMT -4. The time now is 07:49 PM.


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