View Single Post
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