Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 01-31-2015, 12:13 PM   #466
1v4n0
Groupie
1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.
 
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?
1v4n0 is offline   Reply With Quote
Old 02-01-2015, 12:41 AM   #467
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,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).)*
Matches the dot-match-all, if NOT followed by a "string", and then repeats the search ad nauseam.


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
eschwartz is offline   Reply With Quote
Advert
Old 02-02-2015, 06:11 AM   #468
1v4n0
Groupie
1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.
 
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
1v4n0 is offline   Reply With Quote
Old 02-02-2015, 03:04 PM   #469
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,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?
eschwartz is offline   Reply With Quote
Old 02-03-2015, 03:52 AM   #470
1v4n0
Groupie
1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.
 
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.)
1v4n0 is offline   Reply With Quote
Advert
Old 07-08-2015, 04:44 AM   #471
1v4n0
Groupie
1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.
 
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>
I'd like to have a backlink at the end too (makes more sense, especially if the note is very long).

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>
So I need a regex that searches for all the instances of a paragraph starting with a backlink, followed by the closing </p> and zero or more paragraphs until it finds another one that starts with another backlink.

I tried to fiddle with sigil a bit, but to no avail.

Ty
1v4n0 is offline   Reply With Quote
Old 07-08-2015, 11:25 AM   #472
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,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>)
Replace:
Code:
\1\2\3\2
Match 1 is the opening paragraph tag. We could use a positive lookbehind and skip replacing that, but then we can't match optional classes and stuff.

Match 2 (in blue above) captures the link and link text:
Code:
<a [^>]+>[^<>]+</a>
Match 3 (in red above) captures the note content, by matching a string that doesn't contain an "a" tag. I lurves my negative lookarounds :
Code:
(?:(?!</?a(?: [^>]+)?>).)*
Finally, we look ahead to spot the closing paragraph tag.

Last edited by eschwartz; 07-08-2015 at 11:28 AM.
eschwartz is offline   Reply With Quote
Old 07-14-2015, 05:56 PM   #473
1v4n0
Groupie
1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.
 
Posts: 171
Karma: 40000
Join Date: Oct 2013
Device: kindle
Doesn't work. Just finds all the single paragraphs between

Code:
<p><a href=
and
Code:
</p>
Which is the same thing I get with

Code:
<p><a href=(.*?)</p>
I need something that selects everything from one occurrence of

Code:
<p><a href=
to the following one. There are "line breaks" in between (I don't know if that's the right word. Line breaks, something like this

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=(.*?)
The code is barely readable this way though, as there are no line breaks anymore.

Ty
1v4n0 is offline   Reply With Quote
Old 07-15-2015, 12:46 AM   #474
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,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>)
Replace:
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.
eschwartz is offline   Reply With Quote
Old 07-15-2015, 06:52 AM   #475
1v4n0
Groupie
1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.1v4n0 writes the songs that make the whole world sing.
 
Posts: 171
Karma: 40000
Join Date: Oct 2013
Device: kindle
Nope, still the same
1v4n0 is offline   Reply With Quote
Old 07-17-2015, 12:16 AM   #476
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,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>
And my original code worked just fine, becoming:
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.
eschwartz is offline   Reply With Quote
Old 09-02-2015, 11:51 PM   #477
leftright
Addict
leftright makes transoceanic flights without the assistance of an airplaneleftright makes transoceanic flights without the assistance of an airplaneleftright makes transoceanic flights without the assistance of an airplaneleftright makes transoceanic flights without the assistance of an airplaneleftright makes transoceanic flights without the assistance of an airplaneleftright makes transoceanic flights without the assistance of an airplaneleftright makes transoceanic flights without the assistance of an airplaneleftright makes transoceanic flights without the assistance of an airplaneleftright makes transoceanic flights without the assistance of an airplaneleftright makes transoceanic flights without the assistance of an airplaneleftright makes transoceanic flights without the assistance of an airplane
 
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.
leftright is offline   Reply With Quote
Old 09-03-2015, 02:12 AM   #478
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
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>
Doitsu is offline   Reply With Quote
Old 09-03-2015, 02:19 AM   #479
doubleshuffle
Unicycle Daredevil
doubleshuffle ought to be getting tired of karma fortunes by now.doubleshuffle ought to be getting tired of karma fortunes by now.doubleshuffle ought to be getting tired of karma fortunes by now.doubleshuffle ought to be getting tired of karma fortunes by now.doubleshuffle ought to be getting tired of karma fortunes by now.doubleshuffle ought to be getting tired of karma fortunes by now.doubleshuffle ought to be getting tired of karma fortunes by now.doubleshuffle ought to be getting tired of karma fortunes by now.doubleshuffle ought to be getting tired of karma fortunes by now.doubleshuffle ought to be getting tired of karma fortunes by now.doubleshuffle ought to be getting tired of karma fortunes by now.
 
doubleshuffle's Avatar
 
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
Quote:
Originally Posted by leftright View Post
"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."
Totally unrelated to the page number: You really want to get rid of the apostrophes after astronauts and argonauts.
doubleshuffle is offline   Reply With Quote
Old 09-07-2015, 02:34 AM   #480
gipsy
Connoisseur
gipsy began at the beginning.
 
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
In greek language we have sometimes a - before a capital letter, where i can find the unicode rage to exclude them from the finding? I don't want to use something like this
Code:
(?<![\x{0370}-\x{03FF}\x{1F00}-\x{1FFF}])([\x{0370}-\x{03FF}\x{1F00}-\x{1FFF}]+)-(?!\ |\,|\1|\Δ|\Π|\Α|\Ρ|\Χ|\Ν|\Ζ|\Φ)
Thanks
gipsy is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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


All times are GMT -4. The time now is 06:25 AM.


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