def split_on ( s , sep = " " ) : pattern = '''((?:[^%s"']|"[^"]*"|'[^']*')+)''' % sep return [ _strip_speechmarks ( t ) for t in re . split ( pattern , s ) [ 1 : : 2 ] ]
python split string delimter word
Split s by sep unless it s inside a quote .
def split_on(s, sep=" "):
    """Split s by sep, unless it's inside a quote."""
    pattern = '''((?:[^%s"']|"[^"]*"|'[^']*')+)''' % sep

    return [_strip_speechmarks(t) for t in re.split(pattern, s)[1::2]]