Skip to main content

splitBy()

splitBy(str?, splitChar?): string[]

Splits a string by a given character (see defaultJoinChar). Escaped characters (characters preceded by a backslash) will not apply to the split, and the backslash will be removed in the array element. Inverse of joinWith.

Parameters

ParameterTypeDefault value
str?stringundefined
splitChar?stringdefaultJoinChar

Returns

string[]

Example

splitBy('this\\,\\,that,,the other,,,\\,')
// or
splitBy('this\\,\\,that,,the other,,,\\,', ',')
// would return
['this,,that', '', 'the other', '', '', ',']

Defined in

packages/react-querybuilder/src/utils/arrayUtils.ts:15


caution

API documentation is generated from the latest commit on the main branch. It may be somewhat inconsistent with official releases of React Query Builder.