The maxsplit argument indicates the maximum number of splits allowed : Split : Regular Expressions PYTHON TUTORIALS


PYTHON TUTORIALS » Regular Expressions » Split »

 

The maxsplit argument indicates the maximum number of splits allowed


import re


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


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



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Regular Expressions
» Split