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.slice()

Get the subString between two index locations of a String.

Signature

slice(from: Int until: Int) => String

Description

The slice() method extracts the subString between the character offsets from, inclusive, and until, exclusive.

Parameters

Parameter Type Required Description

from

Int

Yes

Starting index of the subString to extract, inclusive, and counted from the left. If from is greater than or equal to the length of the String, the method returns an empty String.

until

Int

Yes

Ending index of the subString to extract, exclusive, and the index is counted from the left. If until is less than from, the method returns an empty String.

Return value

Type Description

String

Substring of characters from the calling string, between the offsets from, inclusive, and until, exclusive.

Examples

Get the subString from index 9 up to, but not including, 15:

"HTTP/1.1 200 OK".slice(9, 15)
"200 OK"

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!