code: def _get_version(name, results):
      '''
      ``pkg search`` will return all packages for which the pattern is a match.
      Narrow this down and return the package version, or None if no exact match.
      '''
      for line in salt.utils.itertools.split(results, '\n'):
          if not line:
              continue
          try:
              pkgname, pkgver = line.rsplit('-', 1)
          except ValueError:
              continue
          if pkgname == name:
              return pkgver
      return Nonf _get_version(name, results):
      '''
      ``pkg search`` will return all packages for which the pattern is a match.
      Narrow this down and return the package version, or None if no exact match.
      '''
      for line in salt.utils.itertools.split(results, '\n'):
          if not line:
              continue
          try:
              pkgname, pkgver = line.rsplit('-', 1)
          except ValueError:
              continue
          if pkgname == name:
              return pkgver
      return None
docs: ``pkg search`` will return all packages for which the pattern is a match.
      Narrow this down and return the package version, or None if no exact match.