code: def get_unit(item, text):
      
      group_units = [1, 4, 6, 8, 10]
      group_operators = [3, 5, 7, 9]
  
      item_units = [item.group(i) for i in group_units if item.group(i)]
  
      if len(item_units) == 0:
          unit = l.NAMES['dimensionless']
      else:
          dimensions, slash = [], False
          for group in sorted(group_units + group_operators):
              if not item.group(group):
                  continue
              if group in group_units:
                  surface, power = parse_unit(item, group, slash)
                  if clf.USE_CLF:
                      base = clf.disambiguate_unit(surface, text).name
                  else:
                      base = l.UNITS[surface][0].name
                  dimensions += [{'base': base, 'power': power}]
              elif not slash:
                  slash = any(i in item.group(group) for i in [u'/', u' per '])
  
          unit = get_unit_from_dimensions(dimensions, text)
  
      logging.debug(u'\tUnit: %s', unit)
      logging.debug(u'\tEntity: %s', unit.entity)
  
      return unit
docs: Extract unit from regex hit.