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 05-10-2014, 12:12 PM   #16
JLius
Village idiot
JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.
 
JLius's Avatar
 
Posts: 157
Karma: 519566
Join Date: Mar 2014
Location: Belgium
Device: sony PRS T-1
I was having trouble with spaces in between tags, e.g

Code:
<p class="P-P27" id="calibre_pb_3"><span class="S-T">1. Title of chapter</span>*</p>
Notice the space between </span> and </p>.

I just couldn't match the search on this - it just worked till the </span>, it failed when I tried to include the </p>

After some googling, I did this:

Code:
<p class="P-P27" id="calibre_pb_3"><span class="S-T">(.+?)</span>\s</p>
And eventually replaced it with this:

Code:
<h1>\1</h1>
Is this sound?
JLius is offline   Reply With Quote
Old 05-10-2014, 12:35 PM   #17
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: 29,818
Karma: 54830978
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 JLius View Post

Notice the space between </span> and </p>.

I just couldn't match the search on this - it just worked till the </span>, it failed when I tried to include the </p>

After some googling, I did this:

Code:
<p class="P-P27" id="calibre_pb_3"><span class="S-T">(.+?)</span>\s*</p>
The * after the \s makes the space optional (\s*)
use a + if there must be 1 or more
theducks is online now   Reply With Quote
Old 05-10-2014, 01:55 PM   #18
JLius
Village idiot
JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.
 
JLius's Avatar
 
Posts: 157
Karma: 519566
Join Date: Mar 2014
Location: Belgium
Device: sony PRS T-1
Thank you!
JLius is offline   Reply With Quote
Old 05-11-2014, 10:10 AM   #19
toothpicz
Junior Member
toothpicz will become famous soon enoughtoothpicz will become famous soon enoughtoothpicz will become famous soon enoughtoothpicz will become famous soon enoughtoothpicz will become famous soon enoughtoothpicz will become famous soon enough
 
toothpicz's Avatar
 
Posts: 6
Karma: 610
Join Date: Aug 2011
Device: Calibre, FBreader(android)
Quote:
Originally Posted by theducks View Post
All escapes are \
So then "\1" refers to keeping all the digits?
What if my titles are alphabets? eg: One, Two... ? Is there a way to keep my original text then?


Quote:
Originally Posted by theducks View Post
BTW bold is no longer needed when changing from P to H#
By default: H# tags are already BOLD
Ahhh. That's why davidfor said to remove the bold tag. Thanks!
toothpicz is offline   Reply With Quote
Old 05-11-2014, 10:46 AM   #20
mrmikel
Color me gone
mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.
 
Posts: 2,089
Karma: 1445295
Join Date: Apr 2008
Location: Central Oregon Coast
Device: PRS-300
\1 in replace will take the place of whatever regular expression was first in find.

Example
Find
Chapter (.+?)

Replace
-CHAPTER \1-

Will give you -CHAPTER 1- replacing Chapter 1, -CHAPTER 2- replacing Chapter 2 and so on. What it gives you depends on the regular expression. If it is ([a-z]) it will give you a lower case letter. If it is ([0-9]) it will give you a single number.

You can have a series of them and so the second expressions capture would be output by \2.

You don't have to use what is found, so you can just use \2 without \1.
mrmikel is offline   Reply With Quote
Old 05-11-2014, 10:58 AM   #21
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: 29,818
Karma: 54830978
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 toothpicz View Post
So then "\1" refers to keeping all the digits?
What if my titles are alphabets? eg: One, Two... ? Is there a way to keep my original text then?
Read this, the editor uses the same REGEX (this is what got through my thick skull and got me using REGEX)

https://www.mobileread.com/forums/sho...d.php?t=118569
theducks is online now   Reply With Quote
Old 05-11-2014, 11:01 AM   #22
mrmikel
Color me gone
mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.
 
Posts: 2,089
Karma: 1445295
Join Date: Apr 2008
Location: Central Oregon Coast
Device: PRS-300
100% with theducks. There is NOTHING regular about regular expressions, except it regularly gives you headaches. Sigil regex is not the same as calibre regex, which is not the same as .....!

BTW be very careful that if your search expression contains a period, you are not set to regex. Period means something in regex beyond just a period, unless it is prefaced with a \. You will get interesting or hair-tearing results...I know. I have.

Last edited by mrmikel; 05-11-2014 at 11:07 AM.
mrmikel is offline   Reply With Quote
Old 05-11-2014, 11:52 AM   #23
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: 29,818
Karma: 54830978
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 mrmikel View Post
100% with theducks. There is NOTHING regular about regular expressions, except it regularly gives you headaches. Sigil regex is not the same as calibre regex, which is not the same as .....!

BTW be very careful that if your search expression contains a period, you are not set to regex. Period means something in regex beyond just a period, unless it is prefaced with a \. You will get interesting or hair-tearing results...I know. I have.
Calibre editor routinely escapes those for you if you find selected text (ctrl-F) to populate the search box
theducks is online now   Reply With Quote
Old 05-11-2014, 01:53 PM   #24
mrmikel
Color me gone
mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.
 
Posts: 2,089
Karma: 1445295
Join Date: Apr 2008
Location: Central Oregon Coast
Device: PRS-300
I didn't know that. I will have to try the shortcut. Save me some steps and headaches.
mrmikel is offline   Reply With Quote
Old 05-13-2014, 05:49 AM   #25
cager
Connoisseur
cager 's ceiling is 100% spider-free.cager 's ceiling is 100% spider-free.cager 's ceiling is 100% spider-free.cager 's ceiling is 100% spider-free.cager 's ceiling is 100% spider-free.cager 's ceiling is 100% spider-free.cager 's ceiling is 100% spider-free.cager 's ceiling is 100% spider-free.cager 's ceiling is 100% spider-free.cager 's ceiling is 100% spider-free.cager 's ceiling is 100% spider-free.
 
Posts: 59
Karma: 118112
Join Date: Jul 2013
Device: none
Thanks, and thanks again, to all who have made comments and extended the original query.
I have found this very useful and instructive. All I need now is the time to experiment.
cager is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Invisible chapter headings? bcamp47 Sigil 6 03-24-2013 12:38 AM
How to mark chapter headings JimLL Sigil 107 06-17-2012 09:02 AM
Chapter Headings Paxman53 Conversion 3 10-12-2011 12:31 PM
Why H1 and H2 Chapter Headings? Ransom Calibre 11 08-10-2011 04:29 PM
Help converting chapter headings p3aul Conversion 6 04-03-2011 12:56 PM


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


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