This endpoint is useful for splitting a given string into an array of substrings based on a specified separator. It is useful when you need to break down a large string into smaller components for easier processing or analysis.
Method: GET
Query Parameters
str
(required): The string to be split. This parameter is mandatory.separator
(optional): The character or string used to split the main string. If not provided, the default separator is a space (‘ ‘).limit
(optional): The maximum number of substrings to return. If not provided, the default is the maximum safe integer value in JavaScript.
Response
substrings
: An array containing the resulting substrings after splitting the original string.
Example Call
URL Format:
GET https://node.nodetrigger.com/split-string?str=<string>&separator=<separator>&limit=<limit>
Real-life Example 1:
Split a sentence into words using a space as the separator:
GET https://node.nodetrigger.com/split-string?str=Hello%20world%20this%20is%20a%20test
Response:
{
"substrings": ["Hello", "world", "this", "is", "a", "test"]
}
Real-life Example 2:
Split a list of items separated by commas, with a limit of 3:
GET https://node.nodetrigger.com/split-string?str=apple,banana,cherry,date&separator=,&limit=3
Response:
{
"substrings": ["apple", "banana", "cherry"]
}