Thread: Regex examples
View Single Post
Old 04-17-2012, 11:11 AM   #61
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,564
Karma: 44355222
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by mncowboy
Is there a single regex that can do this in Sigil?
Thanks in advance.
Find:
Code:
<a href="#_edn(\d+)" name="_ednref(\d+)" title=""><span class="MsoEndnoteReference"><span class="MsoEndnoteReference"><b><span style="font-size:8.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;color:black">\[(\d+)\]</span></b></span></span></a>
Replace:
Code:
<a href="#_edn\1" id="_ednref\2" title=""><sup>[\3]</sup></a>
Or if you know, absolutely, that the numbers will always be the same across each instance:
Find:
Code:
<a href="#_edn(\d+)" name="_ednref\d+" title=""><span class="MsoEndnoteReference"><span class="MsoEndnoteReference"><b><span style="font-size:8.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;color:black">\[\d+\]</span></b></span></span></a>
Replace:
Code:
<a href="#_edn\1" id="_ednref\1" title=""><sup>[\1]</sup></a>
NOTE: I replaced the "name" attribute with "id" because "name" is old and tired.
EDIT: The above stuff is all based on the assumption that the <b>, <span>, and font-family/size stuff is identical in all of the original endnote code instances. You'd need to make judicious use of (.*?) if not.
(and I had a mistake in the first edition of this post that I corrected)

Last edited by DiapDealer; 04-17-2012 at 11:36 AM.
DiapDealer is offline   Reply With Quote