string.splitRegex()

Get a list of Strings, using a regex as a delimiter.

Signature

splitRegex(delimiter: String) => Array<String>

Description

The splitRegex() method returns a list of Strings, using the given regex as the delimiter string.

Multiple, adjacent delimiters in the source string result in an empty element in the result list.

The input string isn’t changed.

Parameters

Parameter Type Required Description

delimiter

String

Yes

Delimiter regex expression.

Return value

Type Description

Array

Array of strings delimited by delimiter.

Examples

'foo bar baz'.splitRegex('\\W+')
[
  "foo",
  "bar",
  "baz"
]

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!