def item_um_from_name(name):
 for um_pattern in um_patterns:
  m = re.search(um_pattern, name)
  if m:
   um = m.group(1).strip()
   name = re.sub(um_pattern, '', name)
   name = re.sub('(,)$', '', name).strip()
   return (name, um)
 return (name, None)

def item_um_from_name ( name ) : for um_pattern in um_patterns : m = re . search ( um_pattern , name ) if m : um = m . group ( 1 ) . strip ( ) name = re . sub ( um_pattern , '' , name ) name = re . sub ( '(,)$' , '' , name ) . strip ( ) return ( name , um ) return ( name , None )
retrieve the unit of measure from a name .