docs: def make_collaborations_regex_str():
      """ From the authors knowledge-base, construct a single regex holding the or'd possibilities of patterns
      which should be included in $h subfields. The word 'Collaboration' is also converted to 'Coll', and
      used in finding matches. Letter case is not considered during the search.
      @return: (string) The single pattern built from each line in the author knowledge base.
      """
      def add_to_auth_list(s):
          """Strip the line, replace spaces with 'backslash s' and append 'the'
          to the start and 's' to the end. Add the prepared line to the list of
          extra kb authors."""
          s = ur"(?:the\s)?" + s.strip().replace(u' ', ur'\s') + u"s?"
          auths.append(s)
  
      # Build the 'or'd regular expression of the author lines in the author
      # knowledge base
      auths = []
      fpath = CFG_REFEXTRACT_KBS['collaborations']
  
      try:
          fh = open(fpath, "r")
      except IOError:
          # problem opening KB for reading, or problem while reading from it:
          LOGGER.debug(u"Error: Could not build knowledge base containing author patterns - failed to read from KB %s s.\n", fpath)
          raise IOError("Error: Unable to open collaborations kb '%s'" % fpath)
  
      for line_num, rawline in enumerate(fh):
          try:
              rawline = rawline.decode("utf-8")
          except UnicodeError:
              LOGGER.debug(u"Unicode problems in %s for line %d", fpath, line_num)
              raise UnicodeError(
                  "Error: Unable to parse collaboration kb (line: %s)" % str(line_num))
          if rawline.strip() and rawline[0].strip() != '#':
              add_to_auth_list(rawline)
              # Shorten collaboration to 'coll'
              if rawline.lower().endswith('collaboration\n'):
                  coll_version = rawline[:rawline.lower().find(
                      u'collaboration\n')] + ur"coll[\.\,]"
                  add_to_auth_list(
                      coll_version.strip().replace(' ', r'\s') + u"s?")
  
      author_match_re = ""
      if len(auths) > 0:
          author_match_re = u'|'.join([u"(?:" + a + u")" for a in auths])
          author_match_re = ur"(?:(?:[\(\"]?(?P<extra_auth>" + \
              author_match_re + ur")[\)\"]?[\,\.]?\s?(?:and\s)?)+)"
  
      return author_match_re