Check out v4 of the Fauna CLI

v4 of the Fauna CLI is now in beta.

The new version introduces enhancements to the developer experience, including an improved authentication workflow. To get started, check out the CLI v4 quick start.

string.splitRegex()

Split a String using a provided regular expression.

Signature

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

Description

Splits the calling String at every occurrence of a provided regular expression, used as a delimiter string.

The calling String isn’t changed. Multiple, adjacent delimiters in the calling String result in an empty element in the resulting Array.

Parameters

Parameter Type Required Description

regex

String

true

Regular expression to split the calling string[] at. Splits at every matching substring. Supports Java regex.

Return value

Type Description

Array<String>

Array of Strings resulting from the split.

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!