From 3657843805a0911fd89b99171dd318218529a327 Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Fri, 9 Jul 2021 20:48:54 +0200 Subject: unstructured: cleanup obsolete regex --- skate/unstructured.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/skate/unstructured.go b/skate/unstructured.go index a12507a..f2c1d21 100644 --- a/skate/unstructured.go +++ b/skate/unstructured.go @@ -8,8 +8,7 @@ import ( var ( PatDOI = regexp.MustCompile(`10[.][0-9]{1,8}/[^ ]*[\w]`) PatDOINoHyphen = regexp.MustCompile(`10[.][0-9]{1,8}/[^ -]*[\w]`) - PatArxivPDF = regexp.MustCompile(`https?://arxiv.org/pdf/([0-9]{4,4}[.][0-9]{1,8})(v[0-9]{1,2})?(.pdf)?`) - PatArxivAbs = regexp.MustCompile(`https?://arxiv.org/abs/([0-9]{4,4}[.][0-9]{1,8})(v[0-9]{1,2})?(.pdf)?`) + PatArxiv = regexp.MustCompile(`https?://arxiv.org/(pdf|abs)/([0-9]{4,4}[.][0-9]{1,8})(v[0-9]{1,2})?(.pdf)?`) DOILinkPrefixes = []string{ "http://doi.org/", "http://dx.doi.org/", @@ -53,14 +52,9 @@ func ParseUnstructured(ref *Ref) error { ref.Biblio.DOI = v } // Arxiv - vs = PatArxivPDF.FindStringSubmatch(uns) + vs = PatArxiv.FindStringSubmatch(uns) if len(vs) != 0 && ref.Biblio.ArxivId == "" { - ref.Biblio.ArxivId = vs[1] - } else { - vs = PatArxivAbs.FindStringSubmatch(uns) - if len(vs) != 0 && ref.Biblio.ArxivId == "" { - ref.Biblio.ArxivId = vs[1] - } + ref.Biblio.ArxivId = vs[2] } // XXX: ISBN ref.Biblio.Extra.ISBN = ParseIsbn(uns) -- cgit v1.2.3