[Tex/LaTex] How to tell LaTeX to automatically remove envelopping curly braces in a string to use with biblatex

biblatexbracesurls

I am using biblatex together with a bibliography manager Referencer. I want to use the url field of the bib file to link to the page. However, Referencer has urls of the form

url = {{ http://... }}

rather than the usual format with only a single brace. Url fields are interpreted literally in biblatex and so I get links to { http:// ... } in the pdf and they consequently do not work. Since every time I change the bibliography file through Referencer the curly braces reappear, going through the bib file and removing the extra braces is not a solution for me. Is there a way to tell LaTeX to automatically remove the braces before passing the result to \href?

Best Answer

Make sure you are using biblatex 2.0+ and biber 1.0+ and put this in your preamble:

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite]{
      \step[fieldsource=url,
            match=\regexp{\A\{(.+)\}\z},
            replace=$1]
    }
  }
}

Of course the regexp can be tuned to your liking. See section 4.5.2 of the current biblatex manual.