[lang-ref] ( string_split_with_regexp ) ( python )

def test_string_split_with_regexp():
    # re.split(d, s)
    import re
    text = 'A, B, C and D'
    pattern = r'(?:,\s*|\s+and\s+)'
    elems = re.split(pattern, text)
    assert elems == ['A', 'B', 'C', 'D']