The maxsplit argument indicates the maximum number of splits allowed: : Split « Regular Expressions « Python Tutorial






import re


some_text = 'alpha, beta,,,,gamma delta'


print re.split('[, ]+', some_text, maxsplit=2)
print re.split('[, ]+', some_text, maxsplit=1)








16.6.Split
16.6.1.with re.split you can split on any sequence of space characters and commas
16.6.2.The maxsplit argument indicates the maximum number of splits allowed:
16.6.3.Split Output of Unix who Command (rewho.py)
16.6.4.Use re package with text file
16.6.5.Regular-expression string manipulation.