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

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 09-30-2018, 02:17 AM   #1
Davvy123
Junior Member
Davvy123 began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Sep 2018
Device: iphone 8 plus
Replacing text in Sigil

Hi, I'm new to Sigil, and just joined Mobileread in order to get some help with editing ebooks and learning how to use Sigil effectively.

My first question is how to use Regular Expressions to edit out or find/replace certain text in an epub. I have seen a Regex tutorial here on these forums, but I'm not very technical, and got lost pretty quickly reading through it. So I'd like to ask if you can help me with an actual problem, once I learn the solution, I think I can work my way back and figure out how to solve my next one on my own.

For example, I have an epub with the following lines:

<p class="calibre2">Hob_0375758275_3p_fm1_r1.qxd 8/30/01 9:35 AM Page iv</p>
<p class="calibre2">Hob_0375758275_3p_fm1_r1.qxd 8/30/01 9:35 AM Page a</p>

There are many other lines like that sprinkled throughout the pub, over several .html pages. Each line has the "Hob_0375758275_3p_fm1_r1.qxd 8/30/01 9:35 AM" string repeated, as well as the tag <p class="calibre2"></p>. And then within the tag there are page numbers, as shown in the above examples, and these change from instance to instance.

I'd like to just get rid of all of these lines of codes. How would I do this? Do I have to work on each .html page, one by one, or can I actually do a bulk find/replace that would span all .html pages and get rid of these lines?

Thanks in advance for your help!
Davvy123 is offline   Reply With Quote
Old 09-30-2018, 10:30 AM   #2
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,093
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
Find: <p class="calibre2">Hob_0375758275_3p_fm1_r1.qxd 8/30/01 9:35 AM Page (.*?)</p>
Replace: (nothing)

The "(.*?)" is like a wildcard for the page numbers: the "." means any single symbol; the "*" means "zero or more times"....so that will find any batch of symbols no matter how long. The "?" means not to be greedy...meaning it will only select the characters before the first "</p>" it finds...not all the way until the last "</p>"at the end of the document. The "()" around it just tells it to remember the symbols that it finds so we can do something with them later using the code \1 (or \2 or \3 etc depending on how many groups you've saved).

In this instance you don't really need them because you are just going to delete them, but if you wanted to do something similar you could replace the page number into it's own paragraph like this:

replace: <p>Page # \1</p>

From your example that would give us:
<p>Page # iv</p>
<p>Page # a</p>

Cheers,

edit: to replace all of them in the whole epub with one button push just make sure you have "All HTML Files" selected at the bottom, not "Current File" and then push the "Replace All" button on the right.
WARNING: The "replace all" button is not reversable so make sure you have saved a backup.

Last edited by Turtle91; 09-30-2018 at 10:34 AM.
Turtle91 is offline   Reply With Quote
Advert
Old 09-30-2018, 02:47 PM   #3
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,775
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Turtle91
I have seen the time increment, so I use:
Find: <p class="calibre2">Hob_0375758275_3p_fm1_r1.qxd 8/30/01 \d:\d\d \wM Page (.*?)</p>
theducks is offline   Reply With Quote
Old 10-01-2018, 05:22 PM   #4
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,093
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
OK. Thanks!

I just went off of what the OP said, but you are right, the time would more than likely increment.
Turtle91 is offline   Reply With Quote
Old 10-03-2018, 12:53 PM   #5
Davvy123
Junior Member
Davvy123 began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Sep 2018
Device: iphone 8 plus
Thank you both for your replies, this worked like a charm, I was able to get rid of all instances of that string.

This particular pub is really full of extraneous metadata information sprinkled throughout the text, is formatted haphazardly, with multiple html files that don't seem to have been cut for any logical rhyme or reason, and on and on.

So I will continue working with it in Sigil. Thank you again, I'll be sure to come back and ask for more help if I get stuck again.

Davvy123 is offline   Reply With Quote
Advert
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Replacing / with correct text ghostyjack Workshop 2 09-11-2013 10:35 AM
Text alignment in Sigil wdaly Sigil 34 01-24-2013 02:45 PM
Sigil: How to highlight text ? Frank's Sigil 65 12-27-2012 07:37 PM
text problems Sigil? ralphiedee Sigil 14 08-09-2012 04:30 AM
Replacing code without replacing text? ElMiko Sigil 6 11-30-2011 08:14 PM


All times are GMT -4. The time now is 03:13 PM.


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