View Single Post
Old 12-16-2011, 01:19 AM   #1
David Kudler
Enthusiast
David Kudler knows the difference between 'who' and 'whom'David Kudler knows the difference between 'who' and 'whom'David Kudler knows the difference between 'who' and 'whom'David Kudler knows the difference between 'who' and 'whom'David Kudler knows the difference between 'who' and 'whom'David Kudler knows the difference between 'who' and 'whom'David Kudler knows the difference between 'who' and 'whom'David Kudler knows the difference between 'who' and 'whom'David Kudler knows the difference between 'who' and 'whom'David Kudler knows the difference between 'who' and 'whom'David Kudler knows the difference between 'who' and 'whom'
 
David Kudler's Avatar
 
Posts: 48
Karma: 10000
Join Date: Apr 2011
Device: iPad
Question Regular expressions - Single back-reference, multiple instances?

I have a huge scanned file (500,000+ words) I'm converting into an ebook. I've got the text more or less converted. I'm now dealing with nearly a thousand footnotes. I don't want to have to hand-code all of the buggers so that they link from the reference to the note and back. I've got all of the note references with code ready to go--they all currently read
Code:
<sup><a href="" name"">NUMBER</a></sup>
(where NUMBER is, obviously, an integer -- the note number).

What I want to do is use a regular expression to help fill in the blanks, so that it looks like this:

Code:
<sup><a href="../Text/Foreword.xhtml#noteNUMBER" name="refNUMBER">NUMBER</a></sup>
Here's the search I tried:

Code:
<sup><a href="" name="">(.*)</a></sup>
And here's my attempted regex:

Code:
<sup><a href="../Text/Foreword.xhtml#note\1" name="ref\1">\1</a></sup>
Unfortunately, when I do get it to work at all, it only finds the first footnote, and munges the code:

Code:
<sup><a href="../Text/Foreword.xhtml#note1"</a></sup>
Any suggestions? Help?

ETA: Okay. Forgot the ? to make the asterisk lazy:

Code:
<sup><a href="" name="">(.*?)</a></sup>
But now the search just crashes the application.

Last edited by David Kudler; 12-16-2011 at 02:26 AM.
David Kudler is offline   Reply With Quote