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, 12:02 PM   #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, 04: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: 162
Karma: 86115
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
Old 03-08-2014, 04: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, 02:39 AM   #319
gipsy
Junior Member
gipsy began at the beginning.
 
Posts: 9
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, 10:34 AM   #320
theducks
Grand Sorcerer
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: 15,045
Karma: 5936659
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
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
Old 04-16-2014, 11: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: 9,393
Karma: 43141350
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, 11:16 AM   #322
theducks
Grand Sorcerer
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: 15,045
Karma: 5936659
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
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, 11:31 AM   #323
Skeeve
Connoisseur
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: 58
Karma: 666666
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, 12:09 PM   #324
Doitsu
Wizard
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: 2,026
Karma: 4825208
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, 12:32 PM   #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: 6,244
Karma: 4801165
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, 12:51 PM   #326
Skeeve
Connoisseur
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: 58
Karma: 666666
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, 01:08 PM   #327
Doitsu
Wizard
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: 2,026
Karma: 4825208
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, 01: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: 644
Karma: 64171
Join Date: Sep 2010
Location: Kent, England, Sol 3, ZZ9 plural Z Alpha
Device: Sony PRS-300, Kobo Aura HD
How about

Find:<i>([^<]*?)τον([^<]*?)</i>
Replace:<i>\1του\2</i>
Perkin is offline   Reply With Quote
Old 04-16-2014, 03: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: 6,244
Karma: 4801165
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, 05:09 PM   #330
gipsy
Junior Member
gipsy began at the beginning.
 
Posts: 9
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 07:00 PM
Accessories Pen examples Gunnerp245 enTourage Archive 15 02-21-2011 04:23 PM
Stylesheet examples? Skitzman69 Sigil 15 09-24-2010 09:24 PM
Examples kafkaesque1978 iRiver Story 1 07-26-2010 04:49 PM
Looking for examples of typos in eBooks Tonycole General Discussions 1 05-05-2010 05:23 AM


All times are GMT -4. The time now is 11:06 PM.


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