|
|
#1 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 15
Karma: 954
Join Date: Aug 2011
Device: NOOK Simple Touch
|
Replacing multiple tags over 2 lines
I have the following source:
Code:
<p class="calibre10"><span class="calibre12 bold">15</span></p>
<p class="calibre2"><span class="calibre4 bold">MAVERICKS</span></p>
Code:
<h1>15<br />
MAVERICKS</h1>
Code:
(Find)<p class="calibre10"><span class="calibre12 bold">(\d\d)</span></p> (Replace with)<h1>\1<br /> |
|
|
|
|
|
#2 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
I think the following might work:
find: Code:
<p class="calibre10"><span class="calibre12 bold">([0-9]{1,})</span></p>\s<p class="calibre2"><span=class="calibre4 bold">([A-Za-z]{1,})</span></p>
Code:
<h1>\1<br />\2</h1> |
|
|
|
| Advert | |
|
|
|
|
#3 | |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 15
Karma: 954
Join Date: Aug 2011
Device: NOOK Simple Touch
|
Quote:
Unfortunately that doesn't do it. The first part of the expression matches, but adding the second fails. According to some old docs, Sigil's RegEx engine is very Perl-like. Perl doesn't normally do multi-line matches, but it can be made to do so. I wonder if we must do something special for multi-line matches. |
|
|
|
|
|
|
#4 |
|
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 657
Karma: 64171
Join Date: Sep 2010
Location: Kent, England, Sol 3, ZZ9 plural Z Alpha
Device: Sony PRS-300, Kobo Aura HD, iPad (Marvin)
|
Change Toxaris' find to
Code:
<p class="calibre10"><span class="calibre12 bold">(\d+)</span></p>\s+<p class="calibre2"><span class="calibre4 bold">(.+)</span></p> |
|
|
|
|
|
#5 | |
|
Jr. - Junior Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 586
Karma: 2000358
Join Date: Aug 2010
Location: Alabama
Device: Archos, Asus, HP, Lenovo, Nexus and Samsung tablets in 7,8 and 10"
|
Quote:
Just trying to figure this regex stuff out. Regards - John |
|
|
|
|
| Advert | |
|
|
|
|
#6 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
|
i usually use \s* & it works fine .
I think the relevant definitions are: \s+ match one or more spaces \s* match none or more spaces |
|
|
|
|
|
#7 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
Forgot the plus sign...
|
|
|
|
|
|
#8 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 15
Karma: 954
Join Date: Aug 2011
Device: NOOK Simple Touch
|
That works beautifully.
An hour's work in seconds -- regexes rule! |
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Touch Dark lines between lines of text | taming | Kobo Reader | 12 | 06-13-2011 07:20 PM |
| Replacing tags after using them | hiperlink | Recipes | 2 | 03-28-2011 10:23 AM |
| Common tags for multiple librairies | poco06 | Calibre | 5 | 11-19-2010 01:51 AM |
| Multiple Tags | luthar28 | Kindle Formats | 0 | 08-05-2010 10:18 PM |
| Bug: entries with multiple formats trigger multiple conversions | flinx1 | Calibre | 12 | 05-21-2010 06:23 AM |