         # Match the regex to the line, and return the match
         line.match(regex)?[0] or ''
 
-
   serialize: -> {
     deserializer: 'ReferenceProvider'
     data: { bibtex: @bibtex, possibleWords: @possibleWords }


      getSuggestions: ({editor, bufferPosition}) ->
        prefix = @getPrefix(editor, bufferPosition)
        new Promise (resolve) ->
          if prefix[0] == "@"
            p = prefix.normalize().replace(/^@/, '')
            suggestions = []
            hits = fuzzaldrin.filter allwords, p, { key: 'author' }
            for h in hits
              h.score = fuzzaldrin.score(p, h.author)
            hits.sort @compare
            resultTemplate = atom.config.get "autocomplete-bibtex.resultTemplate"
            for word in hits
              suggestion = {
                text: resultTemplate.replace("[key]", word.key)
                displayText: word.label
                replacementPrefix: prefix

    # Make sure our list of files is an array, even if it's only one file
    if not Array.isArray(referenceFiles)
      referenceFiles = [referenceFiles]

    try
      references = []

      for file in referenceFiles
        # What type of file is this?
        fileType = file.split('.').pop()

        if fs.statSync(file).isFile()
          if fileType is "json"
            citeprocObject = JSON.parse fs.readFileSync(file, 'utf-8')
            citeprocReferences = citeproc.parse citeprocObject
            references = references.concat citeprocReferences
          else if fileType is "yaml"
            citeprocObject = yaml.load fs.readFileSync(file, 'utf-8')
            citeprocReferences = citeproc.parse citeprocObject
            references = references.concat citeprocReferences
          else
            # Default to trying to parse as a BibTeX file.
            bibtexParser = new bibtexParse fs.readFileSync(file, 'utf-8')
            references = references.concat @parseBibtexAuthors bibtexParser.parse()

          @bibtex = references
        else
          console.warn("'#{file}' does not appear to be a file, so autocomplete-bibtex will not try to parse it.")
    catch error
      console.error error

  prettifyTitle: (title) ->
    return if not title

    # Mendeley wraps title with double {{}}, while the parser
    # only removes one set of those. remove the second set here
    titlecaps(title.replace(/(^\{|\}$)/g, ""))

  parseBibtexAuthors: (citations) ->
    for citation in citations
