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 03-08-2014, 11:02 AM   #316
John Doe
Junior Member
John Doe began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Mar 2014
Device: Android
Thanks! It seems that I just got my self some bedtime reading

Now, if I want to search for something like the above, but dont know how much text there is, how do I do that?

Example:

I search for this:

Code:
<p><a id="id1">This is the text that is in the note and I dont know how much there is. It changes for every note.</a><br /></p>
And want to replace it with this:

Code:
<aside epub:type="footnote">
    <div epub:type="footnote" id="id1"><br />
      <p>This is the text that is in the note and I dont know how much there is. It changes for every note.</p>
    </div>
</aside>
The ID numbers is quite easy after your help, but how do I search and replace the rest without changing the note? I want to replace everything around the note, but the text between "<p>" and "</p>" can be changing from note to note.
John Doe is offline   Reply With Quote
Old 03-08-2014, 03:49 PM   #317
mzmm
Groupie
mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.
 
mzmm's Avatar
 
Posts: 171
Karma: 86271
Join Date: Feb 2012
Device: iPad, Kindle Touch, Sony PRS-T1
regular expressions will be too brittle for this kind of thing. i think you should look into a programmatic way of parsing the html.
mzmm is offline   Reply With Quote
Advert
Old 03-08-2014, 03:54 PM   #318
John Doe
Junior Member
John Doe began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Mar 2014
Device: Android
Don't wanna go into that.

I just simply search/replace in three steps.

But thankyou for your help!
John Doe is offline   Reply With Quote
Old 04-16-2014, 01:39 AM   #319
gipsy
Connoisseur
gipsy began at the beginning.
 
Posts: 81
Karma: 10
Join Date: Nov 2013
Device: Kobo Aura HD
Hi,
there is any way to find the word "τον" between italics and replace it with "του"

For example:
Quote:
<i>Αυτός ο βασιλιάς ζει στη σκιά τον αδερφού τον</i>
must be
Quote:
<i>Αυτός ο βασιλιάς ζει στη σκιά του αδερφού του</i>
Thanks
gipsy is offline   Reply With Quote
Old 04-16-2014, 09:34 AM   #320
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,689
Karma: 54369090
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 gipsy View Post
Hi,
there is any way to find the word "τον" between italics and replace it with "του"

For example:

must be


Thanks
<i>(.*?) tov</i>

<i>\1 tou</i>
theducks is offline   Reply With Quote
Advert
Old 04-16-2014, 10:07 AM   #321
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,468
Karma: 192992430
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
That will only catch the second instance in the given example, Ducks (and only those instances that immediately precede a closing 'i' tag.

Pretty hard to come up with something that will catch multiple occurences only within 'i' tags (without multiple passes anyway). I have no idea how common that word is, but it might be easier to step through each occurence one by one and manually eyeball the ones that are in italic tags.
DiapDealer is offline   Reply With Quote
Old 04-16-2014, 10:16 AM   #322
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,689
Karma: 54369090
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 DiapDealer View Post
I have no idea how common that word is, but it might be easier to step through each occurence one by one and manually eyeball the ones that are in italic tags.
That is the way I would do it
Why spend all the time creating and testing a difficult REGEX for a 1 time use?
Find or Replace Next. The buttons are a tiny mouse move away.
theducks is offline   Reply With Quote
Old 04-16-2014, 10:31 AM   #323
Skeeve
Zealot
Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.
 
Skeeve's Avatar
 
Posts: 142
Karma: 669192
Join Date: Nov 2013
Device: Kindle 4.1.1 no touch
Quote:
Originally Posted by gipsy View Post
Hi,
there is any way to find the word "τον" between italics and replace it with "του"
In perl notation:
Code:
s/τον(?=(?:[^<]+|<[^i]|<i[^>])*?<\/i>)/του/g
Skeeve is offline   Reply With Quote
Old 04-16-2014, 11:09 AM   #324
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
Quote:
Originally Posted by gipsy View Post
Is there is any way to find the word "τον" between italics and replace it with "του"?
The following very simple regex will find one occurrence of "tov" at the beginning, at the end and in the middle of a string of text enclosed by <i></i> tags:

Find:<i>(.*?)τον(.*?)</i>
Replace:<i>\1του\2</i>

You'll, of course, have to run it multiple times to find multiple occurrences of "τον" enclosed by <i></i> tags.
Doitsu is offline   Reply With Quote
Old 04-16-2014, 11:32 AM   #325
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,514
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by Doitsu View Post
The following very simple regex will find one occurrence of "tov" at the beginning, at the end and in the middle of a string of text enclosed by <i></i> tags:

Find:<i>(.*?)τον(.*?)</i>
Replace:<i>\1του\2</i>
But it would also find it between two <i></i> blocks, wouldn't it?

<i>foo</i> τον <i>bar</i>

Even with non-greedy modifier, the asterisk matches as many as needed to make the whole pattern match.
Jellby is offline   Reply With Quote
Old 04-16-2014, 11:51 AM   #326
Skeeve
Zealot
Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.Skeeve ought to be getting tired of karma fortunes by now.
 
Skeeve's Avatar
 
Posts: 142
Karma: 669192
Join Date: Nov 2013
Device: Kindle 4.1.1 no touch
Quote:
Originally Posted by Jellby View Post
But it would also find it between two <i></i> blocks, wouldn't it?

<i>foo</i> τον <i>bar</i>

Even with non-greedy modifier, the asterisk matches as many as needed to make the whole pattern match.
You are absolutely right!

BTW: Mine expression also isn't fool-proof as it would wrongly handle invalid HTML:

<i>foo</i> τον bar</i>
Skeeve is offline   Reply With Quote
Old 04-16-2014, 12:08 PM   #327
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
Quote:
Originally Posted by Jellby View Post
But it would also find it between two <i></i> blocks, wouldn't it?
You're are of course right, but as DiapDealer has already pointed out, it's pretty much impossible to come up with a regex that covers all possible permutations. However, my simple regex covers at least the three most likely scenarios. I.e., an initial, medial or final occurrence of the search string.
Doitsu is offline   Reply With Quote
Old 04-16-2014, 12:39 PM   #328
Perkin
Guru
Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.
 
Perkin's Avatar
 
Posts: 655
Karma: 64171
Join Date: Sep 2010
Location: Kent, England, Sol 3, ZZ9 plural Z Alpha
Device: Sony PRS-300, Kobo Aura HD, iPad (Marvin)
How about

Find:<i>([^<]*?)τον([^<]*?)</i>
Replace:<i>\1του\2</i>
Perkin is offline   Reply With Quote
Old 04-16-2014, 02:00 PM   #329
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,514
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by Perkin View Post
How about

Find:<i>([^<]*?)τον([^<]*?)</i>
Replace:<i>\1του\2</i>
It wouldn't catch:

<i><b>foo</b> τον bar</i>
Jellby is offline   Reply With Quote
Old 04-16-2014, 04:09 PM   #330
gipsy
Connoisseur
gipsy began at the beginning.
 
Posts: 81
Karma: 10
Join Date: Nov 2013
Device: Kobo Aura HD
Thanks for the replies!

I tried the

Find: (<i>)(.*?) (τον)(.*?)(</i>)
Replace: \1\2 του\4\5

and works in many issues.

@theducks there are 3552 "τον" in the doc i use as sample to check.
with the regex. 312
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 08:35 PM.


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