split_and_keep#

split_and_keep(s: str, separators: Union[str, Iterable[str]]) List[str][source]#

Split string by a another substring into a list. Like str.split(), but keeps the separator occurrences in the list.

Parameters
sstr

the string to split

separatorst.Union[str, t.Iterable[str]]

the substring to split by

Returns
——-
t.List[str]

list of substrings, including the separator occurrences in string