Fix skipping trailing empty segments in re.split