summaryrefslogtreecommitdiff
path: root/pypers/marelli/materiale/doctest_talk/split.py
blob: fda986ca6ad76060db3d520ccf0dcc4395ed1730 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# split.py
import re
SEP = re.compile(r"\s*[,;]\s*")
 
def split(text):
    """Split a string taking as separators "," ";".
    Example:
    >>> from split import split
    >>> split("hello, world!; welcome to PyUK!")
    ['hello', 'world!', 'welcome to PyUK!']
    """
    return SEP.split(text)

if __name__ == "__main__":
    import doctest; doctest.testmod()