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 02-01-2012, 09:05 PM   #1
BKh
Zealot
BKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheese
 
BKh's Avatar
 
Posts: 107
Karma: 1000
Join Date: Mar 2011
Device: Kindle
non greedy regEx

In a string like this:
<p class="sgc-9"><a id="v45">The Seven Factors of the Awakened mind—</a><a href="../Text/mainnotes.xhtml#p37-1" id="n151"><sup>151</sup></a><br />
I want to be able to search for this part:
<a id="v45">The Seven Factors of the Awakened mind—</a>
I have tried using
<a id="(.+)">(.*?)</a>
<a id="(.+)">.+?</a>
<a id="(.+)">(.+)?</a>
and
<a id="(.+)">(.+)</a>

But it keeps finding this:
<a id="v45">The Seven Factors of the Awakened mind—</a><a href="../Text/mainnotes.xhtml#p37-1" id="n151"><sup>151</sup></a>
I know it has something to do with greedyness, but I can't figure it out. Didn't there used to be a minimal matching option in a tick box?

The project is to replace the string with this
<span id="\1">\2</span>
because it seems that ADE renders everything in a <a> tag with an underline.
BKh is offline   Reply With Quote
Old 02-01-2012, 09:16 PM   #2
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
Have you tried putting the non-greedy after the </a>?
That is the anchor close you are looking for.
theducks is offline   Reply With Quote
Old 02-01-2012, 09:34 PM   #3
Ahmad Samir
Zealot
Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!
 
Posts: 114
Karma: 5246
Join Date: Jul 2010
Device: none
Make it non-greedy everywhere:
<a id="(.+?)">(.*?)</a>

You were using:
Code:
<a id="(.+)">
which matches all this on its own:
Code:
<a id="v45">The Seven Factors of the Awakened mind—</a><a href="../Text/mainnotes.xhtml#p37-1" id="n151">
Ahmad Samir is offline   Reply With Quote
Old 02-02-2012, 02:52 AM   #4
Serpentine
Evangelist
Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.
 
Posts: 416
Karma: 1045911
Join Date: Sep 2011
Location: Cape Town, South Africa
Device: Kindle 3
Just a reminder, there is an ungreedy flag. (?U).
Serpentine is offline   Reply With Quote
Old 02-02-2012, 03:06 AM   #5
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
Quote:
Originally Posted by Serpentine View Post
Just a reminder, there is an ungreedy flag. (?U).
That is a nice one. I can't seem to find the usage on the net, how must it be used?
Toxaris is offline   Reply With Quote
Old 02-02-2012, 05:36 AM   #6
BKh
Zealot
BKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheese
 
BKh's Avatar
 
Posts: 107
Karma: 1000
Join Date: Mar 2011
Device: Kindle
Quote:
Originally Posted by Ahmad Samir View Post
Make it non-greedy everywhere:
<a id="(.+?)">(.*?)</a>
Brilliant! It works. I would have never figured that out. Thank you so much
BKh is offline   Reply With Quote
Old 02-02-2012, 05:39 AM   #7
BKh
Zealot
BKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheese
 
BKh's Avatar
 
Posts: 107
Karma: 1000
Join Date: Mar 2011
Device: Kindle
Quote:
Originally Posted by Serpentine View Post
Just a reminder, there is an ungreedy flag. (?U).
How exactly would you use that? would you start the whole thing with ?U so it would look like this
?U<a id="(.+)">(.+)</a>
BKh is offline   Reply With Quote
Old 02-02-2012, 06:12 AM   #8
Ahmad Samir
Zealot
Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!
 
Posts: 114
Karma: 5246
Join Date: Jul 2010
Device: none
Quote:
Originally Posted by BKh View Post
How exactly would you use that? would you start the whole thing with ?U so it would look like this
?U<a id="(.+)">(.+)</a>
You can put the flags at the beginning of the string between ( ):
(?U)<a id="(.+)">(.+)</a>

Serpentine posted a link to http://www.pcre.org/pcre.txt some time ago, it's an excellent source of info about PCRE.
Ahmad Samir is offline   Reply With Quote
Old 02-02-2012, 08:01 AM   #9
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
Posts: 2,488
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
Quote:
Originally Posted by Ahmad Samir View Post
Serpentine posted a link to http://www.pcre.org/pcre.txt some time ago, it's an excellent source of info about PCRE.
Look for the PCRESYNTAX section.
user_none is offline   Reply With Quote
Old 02-02-2012, 08:07 AM   #10
BKh
Zealot
BKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheeseBKh can extract oil from cheese
 
BKh's Avatar
 
Posts: 107
Karma: 1000
Join Date: Mar 2011
Device: Kindle
Again, thank you so much. I would have never figured it out on my own.
BKh is offline   Reply With Quote
Old 02-02-2012, 09:20 AM   #11
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 user_none View Post
Look for the PCRESYNTAX section.
John,
How about putting the PCRE link directly on the Sigil Help Menu (more than 1 Help link instead of having to drill down)
theducks 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
Is this greedy? Sydney's Mom General Discussions 38 05-01-2011 03:38 PM
Curse of the Greedy Copyright Holders Steven Lake Writers' Corner 12 07-16-2010 06:47 PM
Why are academic publishers so greedy? random50 Amazon Kindle 13 02-02-2009 08:42 AM
Just arrived in my greedy little hands.... MWetherspoon iRex 1 03-03-2008 05:16 PM
Greedy publisher cashes in with e-books Colin Dunstan News 3 10-19-2005 03:26 PM


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


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