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

Get the index of the matching String given a regex.

Signature

indexOfRegex(regex: String) => Number | Null

indexOfRegex(regex: String, index: Number) => Number | Null

Description

Gets the index in the source string that matches regex, starting at index.

Parameters

Parameter Type Required Description

regex

String

Yes

Regex to match against the source string. Supports Java regex.

index

Number

Source string location to start matching against regex.
default = 0

Return value

Type Description

Number

Index of match with regex.

Null

Match not found.

Examples

'foo 123'.indexOfRegex('[0-9]')
4
'foo 123 abc 5678'.indexOfRegex('[0-9]', 10)
12

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!