SubString

Not available in this language yet.
SubString( value, start, [ length ] )
SubString( value, start, [ length ] )
SubString( value, start, [ length ] )
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
SubString( value, start, [ length ] )

Description

The SubString function returns a portion of the value string beginning at the character start position for length characters long.

Parameters

Argument Type Definition and Requirements

value

String

The string having the subset returned.

start

Integer

The position in the source string where the SubString function starts to return characters. The first position in the string is 0. If start is 0 or positive, then offset is from the first code point in the source string. If start is negative, the offset is backwards from the end of the source string. A value of -1 returns the last character in the source string.

length

Integer

Optional - The number of code points to extract. The default returns the remaining portion of the source string after beginning at start character.

Returns

A string value which has the described string extracted.

Examples

The query below executes an array of independent SubString operations and returns the results in an array. The result array position matches the execution array position. The first operation takes a source string containing "ABCDEFGHIJK" and extracts a string starting at the 2 position for 3 characters. The resultant string "CDE" is placed in the top position of the result array. The second operation uses the same input string, but starts at the 1 position ("B") and extracts 6 characters("BCDEFG"). The third operations extracts the last 4 characters from the end of the source string.

System.out.println(
  client.query(
    Arr(
       SubString("ABCDEFGHIJK",2,3),
       SubString("ABCDEFGHIJK",1,6),
       SubString("ABCDEFGHIJK",-4),
       SubString("ABCDEFGHIJK",-3, 2)
    )
  ).get());
[
  "CDE",
  "BCDEFH",
  "HIJK",
  "IJ"
]

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve! documentation@fauna.com

Thank you for your feedback!