Archive retitler bugfix

I found and fixed a small bug in the archive-page retitling script described in a recent column . The following line:

regex.subst ("#title .+", "#title " + scratchpad.title + "\r\n" + scratchpad.archiveFile, @scratchpad.archiveFile);

should instead be:

regex.subst ("#title [^\r\n]+\r\n", "#title " + scratchpad.title + "\r\n", @scratchpad.archiveFile);

There were two problems. First, the dot-plus didn't mean match-to-next-newline as I had assumed, but rather match the whole multiline string of metadata grabbed from the file. Second, I was erroneously including that whole string in the replacement. This had the effect of stacking up titles in cases of more than one titled item per day, like so:

#title3
#title2
#title1

It wasn't a bad problem, because #title3 was the one I wanted, and that's the one Radio used. Anyway, fixed.


Former URL: http://weblog.infoworld.com/udell/2002/05/08.html#a225