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-18-2014, 05:59 PM   #1
keele
Junior Member
keele began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Sep 2014
Device: Kindle
Fin/ replace a generic string

Good evening/day,

i'm trying to edit an ebook, I read the help section about finding/replacing, unfortunately, it seems I can't handle this all by my self.

I'm trying to replace this character string in an ebook :

Code:
<p class="calibre2"><img src="index-***_*.png" class="calibre1"/></p>
"*" are numbers, I read about the [0-9] approach but didn't manage to make it work.

Anyone can help me please?

Regards
Keele
keele is offline   Reply With Quote
Old 09-18-2014, 06:24 PM   #2
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 22,767
Karma: 128728422
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
If the numbers in the calibre class names won't ever change, then:

Code:
<p class="calibre2"><img src="index-\d+_\d.png" class="calibre1"/></p>
in regex search-mode to find.

Sorta need to know what you want to replace it with to know what to capture to build the replace expression.
DiapDealer is offline   Reply With Quote
Advert
Old 09-18-2014, 07:06 PM   #3
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,372
Karma: 83251084
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Also, if you plan on doing this a lot, you might want to read a regex guide. The most helpful one I have found (and which managed to drill regex into my head ) is this: http://regular-expressions.info
eschwartz is offline   Reply With Quote
Old 09-19-2014, 03:07 PM   #4
keele
Junior Member
keele began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Sep 2014
Device: Kindle
Quote:
Originally Posted by DiapDealer View Post
If the numbers in the calibre class names won't ever change, then:

Code:
<p class="calibre2"><img src="index-\d+_\d.png" class="calibre1"/></p>
in regex search-mode to find.

Sorta need to know what you want to replace it with to know what to capture to build the replace expression.
Thanks a lot, that worked pefectly, I just needed to remove a watermark someone put on a copyright free ebook. Quite viciously though, as an image file. 894 occurences where swipped! Thanks a lot.

Quote:
Originally Posted by eschwartz View Post
Also, if you plan on doing this a lot, you might want to read a regex guide. The most helpful one I have found (and which managed to drill regex into my head ) is this: http://regular-expressions.info
I took a peek and it looked very exhaustive. Unfortunately, I'm but an amateur programmer, barely able to make a Javascript function, regular expressions are a whole new world to me, it's not the first time I heard of it and I hope I'll be able to master it because it really seems to be a powerfull "tool".
keele is offline   Reply With Quote
Old 09-19-2014, 03:46 PM   #5
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,372
Karma: 83251084
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Quote:
Originally Posted by keele View Post
I took a peek and it looked very exhaustive. Unfortunately, I'm but an amateur programmer, barely able to make a Javascript function, regular expressions are a whole new world to me, it's not the first time I heard of it and I hope I'll be able to master it because it really seems to be a powerfull "tool".
Well, it gets easier as you get more familiar with it.

There is both a lengthy tutorial and a Quick Start guide: http://www.regular-expressions.info/quickstart.html

The Quick Start gives you simple basics with "Learn more about ____" links to the exhaustive guide sections. It is very easy to go back and forth as needed.

My favorite aspect of the guide is the breakdown of what the regex engine is doing to figure out the match. A little involved, but it helped me get clear in my head the rules of precedence for various things.

Good luck!
eschwartz is offline   Reply With Quote
Advert
Reply

Tags
find, regular, replace, string

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace field with match or empty string? charlweed Library Management 2 03-29-2012 12:44 AM
Regex - replace only part of a string - how? flameproof Sigil 11 02-23-2012 04:43 AM
Mathch a string while ignoring some character in that string? ElMiko Sigil 12 12-01-2011 10:05 PM
Find and replace string with wildcard jhempel24 Sigil 15 11-12-2010 01:50 PM


All times are GMT -4. The time now is 12:24 AM.


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