:func:`re.split`). Splitting an empty string with a specified separator
returns ``['']``.
- For example::
+ For example:
+
+ .. doctest::
>>> '1,2,3'.split(',')
['1', '2', '3']
string or a string consisting of just whitespace with a ``None`` separator
returns ``[]``.
- For example::
+ For example:
+
+ .. doctest::
>>> '1 2 3'.split()
['1', '2', '3']
If *sep* is not specified or is ``None`` and *maxsplit* is ``0``, only
leading runs of consecutive whitespace are considered.
- For example::
+ For example:
+
+ .. doctest::
>>> "".split(None, 0)
[]
>>> " foo ".split(maxsplit=0)
['foo ']
- See also :meth:`join`.
+ See also :meth:`join` and :meth:`rsplit`.
.. index::