Fix globally scoped variable and change match(...).join("") to match(...)[0]

This commit is contained in:
Dan Stillman 2009-04-07 01:10:03 +00:00
parent 414680d7be
commit 2480b04f10

View file

@ -86,9 +86,9 @@ function lookupPMIDs(ids, doc) {
if (article.Pagination.MedlinePgn.length()){
var fullPageRange = article.Pagination.MedlinePgn.text().toString();
var pageRange = fullPageRange.match(/\d+-\d+/g);
for (i in pageRange) {
var pageRangeStart = pageRange[i].match(/^\d+/).join("");
var pageRangeEnd = pageRange[i].match(/\d+$/).join("");
for (var i in pageRange) {
var pageRangeStart = pageRange[i].match(/^\d+/)[0];
var pageRangeEnd = pageRange[i].match(/\d+$/)[0];
if (pageRangeStart.length > pageRangeEnd.length) {
pageRangeEnd = pageRangeStart.substring(0,pageRangeStart.length-pageRangeEnd.length) + pageRangeEnd;
fullPageRange = fullPageRange.replace(pageRange[i],pageRangeStart+"-"+pageRangeEnd);