splitBy()
splitBy(
str?:string,splitChar?:string):string[]
Defined in: packages/core/src/utils/arrayUtils.ts:24
Splits a string by a given character (see defaultJoinChar). A backslash escapes
the split character's first character or another backslash; escaped characters don't
apply to the split, and the escaping backslash is removed. Other backslashes are preserved
(e.g. C:\path). Inverse of joinWith for non-empty split characters.
When the split character starts with a backslash, the escape character is / instead.
With an empty split character, the string is split into individual characters. Since joinWith concatenates elements in that case, original boundaries can't be recovered.
Parameters
| Parameter | Type | Default value |
|---|---|---|
str? | string | undefined |
splitChar? | string | defaultJoinChar |
Returns
string[]
Example
splitBy('this\\,\\,that,,the other,,,\\,')
// or
splitBy('this\\,\\,that,,the other,,,\\,', ',')
// would return
['this,,that', '', 'the other', '', '', ',']
API documentation is generated from the latest commit on the main branch. It may be somewhat inconsistent with official releases of React Query Builder.