01-31-2015, 12:13 PM | #466 |
Groupie
Posts: 171
Karma: 40000
Join Date: Oct 2013
Device: kindle
|
More idle questions: some way to match everything except a specific string, or a set of specific strings?
|
02-01-2015, 12:41 AM | #467 |
Ex-Helpdesk Junkie
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Yep, with a negative lookaround (see HERE for the first explanation I saw, way back, of this trick):
Code:
((?!string).)* regex is not meant to do this sort of stuff, but it can be shoehorned into it. There will be a performance hit, but how often does that become a practical matter? Last edited by eschwartz; 02-02-2015 at 03:02 PM. Reason: if followed != if not followed. :o |
Advert | |
|
02-02-2015, 06:11 AM | #468 |
Groupie
Posts: 171
Karma: 40000
Join Date: Oct 2013
Device: kindle
|
Weird. This finds the first string in the xhtml file, but when I re-click "find" it skips to the next file, instead of finding the second string of the file, i.e. the second interval between the "excluded" strings. If I position the pointer after the excluded string it finds the right stuff, but I have to do it manually each time.
Anyway ty. What I'm thinking about is even more complicated: I got a text with lots of line-breaks, <br/>, and I want to wrap the first of each three lines into a span. I could achieve the same goal with some <p> and nth-child css, but they're not as widely supported. Hope this all makes sense |
02-02-2015, 03:04 PM | #469 |
Ex-Helpdesk Junkie
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
I suspect you could also do the same with manually declared classes what difference does it make whether they are wrapped in spans or ps?
|
02-03-2015, 03:52 AM | #470 |
Groupie
Posts: 171
Karma: 40000
Join Date: Oct 2013
Device: kindle
|
Well I found out (at my expense ) that I can't nest p's, though calibre does not make it clear immediately, and what I'm working on is already in a p. But anyway, this is details. Even if I were to use <p>'s, what difference would it make? I'd still need to select the first of every three.
(This is for some poetry, in which the first verse of evry tercet is more indented than the other two.) |
Advert | |
|
07-08-2015, 04:44 AM | #471 |
Groupie
Posts: 171
Karma: 40000
Join Date: Oct 2013
Device: kindle
|
select multiple p's until you find a different one
I got some footnotes. Some of them are one paragraph only, others are longer. They only have "backlinks" to the main text at the beginning of the note
Code:
<p><a href="#13" id="13-fn">13.</a> bla bla bla</p> <p>alb alb alb</p> Code:
<p><a href="#13" id="13-fn">13.</a> bla bla bla</p> <p>alb alb alb<a href="#13">back to text</a></p> I tried to fiddle with sigil a bit, but to no avail. Ty |
07-08-2015, 11:25 AM | #472 |
Ex-Helpdesk Junkie
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Try:
Find: Code:
(<p(?: [^>]+)?>)(<a [^>]+>[^<>]+</a>)((?:(?!</?a(?: [^>]+)?>).)*)(?=</p>) Code:
\1\2\3\2 Match 2 (in blue above) captures the link and link text: Code:
<a [^>]+>[^<>]+</a> Code:
(?:(?!</?a(?: [^>]+)?>).)* Last edited by eschwartz; 07-08-2015 at 11:28 AM. |
07-14-2015, 05:56 PM | #473 |
Groupie
Posts: 171
Karma: 40000
Join Date: Oct 2013
Device: kindle
|
Doesn't work. Just finds all the single paragraphs between
Code:
<p><a href= Code:
</p> Code:
<p><a href=(.*?)</p> Code:
<p><a href= Code:
</p> <p> THIS WORKS, but it's not very clean work: First, find all the occurrences of \s+ and replace with space. Then look for Code:
<p><a href=(.*?)<p><a href=(.*?) Ty |
07-15-2015, 12:46 AM | #474 |
Ex-Helpdesk Junkie
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
What about:
Find: Code:
(<p(?: [^>]+)?>)(<a [^>]+>[^<>]+</a>)((?:(?!</?[ap](?: [^>]+)?>).)*)(?=</p>) Code:
\1\2\3\2 I should've made it find text without "a" or "p" tags. EDIT: No, not sure what I was thinking of at all. That makes no sense... Last edited by eschwartz; 07-17-2015 at 12:13 AM. |
07-15-2015, 06:52 AM | #475 |
Groupie
Posts: 171
Karma: 40000
Join Date: Oct 2013
Device: kindle
|
Nope, still the same
|
07-17-2015, 12:16 AM | #476 |
Ex-Helpdesk Junkie
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Tested in calibre editor on the content:
Code:
<p><a href="#13" id="13-fn">13.</a> bla bla bla</p> <p>alb alb alb</p> <p><a href="#14" id="14-fn">14.</a> bla bla bla</p> <p>alb alb alb</p> <p><a href="#15" id="15-fn">15.</a> bla bla bla</p> <p>alb alb alb</p> <p><a href="#16" id="16-fn">16.</a> bla bla bla</p> <p>alb alb alb</p> Code:
<p><a href="#13" id="13-fn">13.</a> bla bla bla</p> <p>alb alb alb<a href="#13" id="13-fn">13.</a></p> <p><a href="#14" id="14-fn">14.</a> bla bla bla</p> <p>alb alb alb<a href="#14" id="14-fn">14.</a></p> <p><a href="#15" id="15-fn">15.</a> bla bla bla</p> <p>alb alb alb<a href="#15" id="15-fn">15.</a></p> <p><a href="#16" id="16-fn">16.</a> bla bla bla</p> <p>alb alb alb<a href="#16" id="16-fn">16.</a></p> So I'm not sure what problem you were having. As for post #474 I am not sure what, if any, thought processes were running through my mind! Last edited by eschwartz; 07-17-2015 at 12:19 AM. |
09-02-2015, 11:51 PM | #477 |
Addict
Posts: 224
Karma: 55704
Join Date: Sep 2013
Device: Kobo Glo
|
Find numbers between sentences and remove ?
Can someone help me with the syntax for the following please,
I want to remove the numbers between these sentences and then append the sentences as in below, "The cat jumped over the moon many times before astronauts' or argonauts' 37 ever manged to do so, even before any cow attempted this amazing feat, and when it succeeded, milk shake for everyone." It appears as <p class="calibre1">37</p> It should be; "The cat jumped over the moon many times before astronauts' or argonauts' ever manged to do so, even before any cow attempted this amazing feat, and when it succeeded, milk shake for everyone." Many thanks. Last edited by leftright; 09-02-2015 at 11:57 PM. |
09-03-2015, 02:12 AM | #478 |
Grand Sorcerer
Posts: 5,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
|
There are probably more elegant solutions, but the following expression should do the trick assuming that the text before and after the page number is also wrapped in paragraph tags:
Find:<p([^>]*)>(.*?)</p>\s*<p[^>]*>\d+</p>\s*<p[^>]*>(.*?)</p> Replace:<p\1>\2 \3</p> |
09-03-2015, 02:19 AM | #479 |
Unicycle Daredevil
Posts: 13,923
Karma: 185041098
Join Date: Jan 2011
Location: Planet of the Pudding Brains
Device: Aura HD (R.I.P. After six years the USB socket died.) tolino shine 3
|
Totally unrelated to the page number: You really want to get rid of the apostrophes after astronauts and argonauts.
|
09-07-2015, 02:34 AM | #480 |
Connoisseur
Posts: 81
Karma: 10
Join Date: Nov 2013
Device: Kobo Aura HD
|
Hi,
i user the following regex to check for hypen errors Code:
FIND:(?<![\x{0370}-\x{03FF}\x{1F00}-\x{1FFF}])([\x{0370}-\x{03FF}\x{1F00}-\x{1FFF}]+)-(?!\ |\,|\1) REPLACE:\1 Code:
(?<![\x{0370}-\x{03FF}\x{1F00}-\x{1FFF}])([\x{0370}-\x{03FF}\x{1F00}-\x{1FFF}]+)-(?!\ |\,|\1|\Δ|\Π|\Α|\Ρ|\Χ|\Ν|\Ζ|\Φ) |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Examples of Subgroups | emonti8384 | Lounge | 32 | 02-26-2011 06:00 PM |
Accessories Pen examples | Gunnerp245 | enTourage Archive | 15 | 02-21-2011 03:23 PM |
Stylesheet examples? | Skitzman69 | Sigil | 15 | 09-24-2010 08:24 PM |
Examples | kafkaesque1978 | iRiver Story | 1 | 07-26-2010 03:49 PM |
Looking for examples of typos in eBooks | Tonycole | General Discussions | 1 | 05-05-2010 04:23 AM |