Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 03-04-2012, 02:55 PM   #1
Gunnerp245
Gadget Freak
Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.
 
Gunnerp245's Avatar
 
Posts: 1,169
Karma: 1043832
Join Date: Nov 2007
Location: US
Device: EE, Note 8
Regex

I have a book with 25 chapters where the 'Chapter' is in the same font size as the rest of the text; It looks like this;
<p class="calibre2"> CHAPTER ## </p>, where ## is the number 1 to 25.

I have devised the following which finds all the chapter entries;
<p class="calibre2">\sCHAPTER\s*\d*\s</p>

I would like to replace it with something similar to;
<h2 class="calibre3">CHAPTER ## </h2>, where ## is the number 1 to 25.

But am unable to devise the correct sequence to save the ## from the search function and insert into the replace function. I read about back referencing including viewing "An introduction to regular expressions" and "Using the Search & Replace feature" without success.

Gunnerp245 is offline   Reply With Quote
Old 03-04-2012, 03:48 PM   #2
JustForFun
Enthusiast
JustForFun has learned how to read e-booksJustForFun has learned how to read e-booksJustForFun has learned how to read e-booksJustForFun has learned how to read e-booksJustForFun has learned how to read e-booksJustForFun has learned how to read e-booksJustForFun has learned how to read e-books
 
Posts: 30
Karma: 752
Join Date: Nov 2010
Device: PB360
Use
Code:
<p class="calibre2">\sCHAPTER\s*(\d*)\s</p>
for search and
Code:
<h2 class="calibre3">CHAPTER \1</h2>
for replace.

If you need more than one part of the searched text, surround each needed part with parentheses. In the replacement, use backslash and number where the number is the result of numbering the parentheses from left to right, starting with one.

Last edited by JustForFun; 03-04-2012 at 03:51 PM.
JustForFun is offline   Reply With Quote
Advert
Old 03-04-2012, 06:42 PM   #3
Gunnerp245
Gadget Freak
Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.
 
Gunnerp245's Avatar
 
Posts: 1,169
Karma: 1043832
Join Date: Nov 2007
Location: US
Device: EE, Note 8
@JustForFun

Quote:
<h2 class="calibre3">CHAPTER \1</h2>
Works like a champ. I could have sworn I tried that sequence.

If I had left a space after the \1 would it have matter?

Assistance much appreciated!
Gunnerp245 is offline   Reply With Quote
Old 03-04-2012, 08:59 PM   #4
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,782
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 Gunnerp245 View Post
@JustForFun



Works like a champ. I could have sworn I tried that sequence.

If I had left a space after the \1 would it have matter?

Assistance much appreciated!
any space in the replace, just get inserted. In this case, you would not see the difference.
Chapter \1: \2
Where the \2 represents the sub-title match

results ex.
Chapter 2: The next Step
theducks is offline   Reply With Quote
Old 03-04-2012, 10:24 PM   #5
ldolse
Wizard
ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.
 
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
On a side note - the heuristics detect chapters feature should do this for you automatically.
ldolse is offline   Reply With Quote
Advert
Old 03-05-2012, 04:15 PM   #6
Gunnerp245
Gadget Freak
Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.
 
Gunnerp245's Avatar
 
Posts: 1,169
Karma: 1043832
Join Date: Nov 2007
Location: US
Device: EE, Note 8
Thanks all.
Gunnerp245 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
New help with a regex txckie Calibre 2 08-29-2011 08:46 PM
Help me with regex please. eVrajka Library Management 5 08-15-2011 12:17 PM
Regex Faster Sigil 2 04-24-2011 09:08 PM
What a regex is Worldwalker Calibre 20 05-10-2010 05:51 AM
Regex help... Bobthebass Workshop 6 04-26-2009 03:54 PM


All times are GMT -4. The time now is 06:24 PM.


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