import re


def str2list(word, dl=','):
  """
  Test cases:
  'train'               =>  ['train']
  'train,val,test'      =>  ['train', 'val', 'test']
  'train,   val, test'  =>  ['train', 'val', 'test']
  'train,   val, ,test' =>  ['train', 'val', 'test']
  'train,   val, ,'     =>  ['train', 'val']
  """
  regexp = re.compile(r'['+dl+']')
  if regexp.search(word):
    x = word.split(',')
    x = [i.strip() for i in x if i.strip() ]
  else:
    x = [word]
  return x