split
Splits a string into a list of substrings based on a specified delimiter.
Syntax
split(text)
split(text, delimiter)
split(text, delimiter, maxsplit)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| text | string | Yes | The source string to split. |
| delimiter | string | Optional | The substring to use as the split point. Defaults to ",". |
| maxsplit | integer | Optional | The maximum number of splits to perform. Defaults to -1, which splits at every occurrence. |
Returns
Type: list[string]
A list of substrings resulting from the split operation.
Examples
Split a comma-separated value:
split([categories])
If categories is "Network,Hardware,Software", the result is ["Network", "Hardware", "Software"].
Split with a custom delimiter:
split([full_name], " ")
If full_name is "Jane Marie Doe", the result is ["Jane", "Marie", "Doe"].
Limit the number of splits:
split("one:two:three:four", ":", 2)
Result: ["one", "two", "three:four"].
Notes
- If the delimiter is not found in the string, the result is a single-element list containing the entire string.
- The
textargument must be a string. Passing a non-string value raises aTypeError. - The default delimiter is a comma (
","), making this function convenient for CSV-style values.
Comments
0 comments
Please sign in to leave a comment.