SPLIT
Description
The SPLIT
function is used to split a string (str
) into multiple substrings based on a specified regular expression (regex
), and store these substrings in an array. This function is very useful when processing and analyzing text data, as it can help you quickly extract the required information.
Parameters
str
(string): The original string to be split.regex
(string): The regular expression used to define the splitting rules.limit
(int, optional): The maximum length of the returned array. Whenlimit
is greater than 0, the length of the returned array will not exceed the value specified bylimit
. Whenlimit
is less than or equal to 0, it means that the length of the array is not limited. The default value is 0.
Return Value
Returns an array (array<string>
) containing the split substrings.
Example
Example 1: Basic usage
Results:
Example 2: Limit the length of the returned array
Results:
Example 3: Using different delimiters
Results:
Example 4: Handling Nested Delimiters
Results:
Example 5: Using with the limit
parameter
Results: