pyxx.strings.split_at_index#
- pyxx.strings.split_at_index(value: str, index: int, return_index: bool = False) tuple#
Splits a string at a given index
This function can be used to split a string at a given position, returning the parts of the string before and after the given index, and optionally returning the character located at the index at which the string was split.
- Parameters:
value (str) – String to split
index (int) – Index specifying position at which to split
valuereturn_index (bool, optional) – Whether to include the character located at
indexin the tuple of strings returned by the function (default isFalse)
- Returns:
A tuple containing the portions of
valuebefore and after the position specified byindex, and possibly the valuevalue[index](see Notes section for format details)- Return type:
tuple
Notes
Suppose that
begin,delimiter, andendare strings, and thatvalue = f'{begin}{delimiter}{end}', whereindex = len(begin).If
return_index = False, the following tuple is returned:(begin, end)If If
return_index = True, the following tuple is returned:(begin, delimiter, end)