![]() |
#1 |
Gadget Freak
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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 ![]() ![]() ![]() |
![]() |
![]() |
![]() |
#2 |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30
Karma: 752
Join Date: Nov 2010
Device: PB360
|
Use
Code:
<p class="calibre2">\sCHAPTER\s*(\d*)\s</p> Code:
<h2 class="calibre3">CHAPTER \1</h2> 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. |
![]() |
![]() |
![]() |
#3 | |
Gadget Freak
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,169
Karma: 1043832
Join Date: Nov 2007
Location: US
Device: EE, Note 8
|
@JustForFun
Quote:
![]() If I had left a space after the \1 would it have matter? ![]() Assistance much appreciated! ![]() |
|
![]() |
![]() |
![]() |
#4 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,047
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
Chapter \1: \2 Where the \2 represents the sub-title match results ex. Chapter 2: The next Step |
|
![]() |
![]() |
![]() |
#5 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
|
![]() |
![]() |
![]() |
#6 |
Gadget Freak
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,169
Karma: 1043832
Join Date: Nov 2007
Location: US
Device: EE, Note 8
|
Thanks all.
|
![]() |
![]() |
![]() |
|
![]() |
||||
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 |