Python regex `split` function

Python regex split() function explained with examples.

Python string splitter

The split() funtion, splits a string by the occurrences of a pattern.

Syntax

re.split(pattern, string, maxsplit=0, flags=0)

If maxsplit is nonzero, at most maxsplit splits occur, and the remainder of the string is returned as the final element of the list.

Get hands-on with 1200+ tech skills courses.