def selectSome(strings, requiredsubstrings=[], requireAll=True):
 if (len(requiredsubstrings) == 0):
  return strings
 res = []
 for s in strings:
  if requireAll:
   bad = False
   for rs in requiredsubstrings:
    if (s.find(rs) < 0):
     bad = True
     break
   if (not bad):
    res.append(s)
  else:
   for rs in requiredsubstrings:
    if (s.find(rs) >= 0):
     res.append(s)
     break
 return res

def selectSome ( strings , requiredsubstrings = [ ] , requireAll = True ) : if ( len ( requiredsubstrings ) == 0 ) : return strings res = [ ] for s in strings : if requireAll : bad = False for rs in requiredsubstrings : if ( s . find ( rs ) < 0 ) : bad = True break if ( not bad ) : res . append ( s ) else : for rs in requiredsubstrings : if ( s . find ( rs ) >= 0 ) : res . append ( s ) break return res
filter the list of strings to only contain those that have at least one of the required substrings .