Method Name:
rsplit
Method Signature:
rsplit(sep=None, maxsplit=-1)
Method Overview:
- The rsplit() method tokenizes a string based on a delimiter-substring and returns a list of tokens.
- Both the delimiter-substring and the number of splits can be specified using sep, maxsplit parameters.
- Tokenizing starts at the highest index at which the delimiter-substring specified by the sep is found.
Example:
csvString = "t1,t2,t3,t4" tokens = csvString.rsplit(",") print(tokens) tokens = csvString.rsplit(",",2) print(tokens) |
Output:
['t1', 't2', 't3', 't4'] ['t1,t2', 't3', 't4'] |
Example:
csvString = "v1||v2||v3||v4" tokens = csvString.rsplit("||") print(tokens) tokens = csvString.rsplit("||",2) print(tokens) |
Output:
['v1', 'v2', 'v3', 'v4'] ['v1||v2', 'v3', 'v4'] |