One particular quirk of the (otherwise quite powerful) re
module in Python is that re.split()
will never split a string on a zero-length match, for example if I want to split a string along word boundaries:
>>> re.split(r"\s+|\b", "Split along words, preserve punctuation!")
['Split', 'along', 'words,', 'preserve', 'punctuation!']
instead of
['', 'Split', 'along', 'words', ',', 'preserve', 'punctuation', '!']
Why does it have this limitation? Is it by design? Do other regex flavors behave like this?