FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date. Fauna accounts created after August 21, 2024 must use FQL v10. These accounts will not be able to run FQL v4 queries or access the v4 Dashboard. For more details, see the v4 EOL announcement and migration guide. Contact support@fauna.com with any questions. |
SubString
This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics. |
SubString( value, start, [ length ] )
substring( value, start, [ length ] )
SubString( value, start, [ length ] )
SubString( value, start, [ length ] )
SubString( value, start, [ length ] )
SubString( value, start, [ length ] )
Description
The SubString
function extracts a substring out of the value
string,
beginning at the character start
position, and including length
characters (or all remaining characters if length
is not specified).
For the set of letters in the alphabet, setting start
to 3 and
length
to 3 results in the substring DEF
:
Although we mention characters, technically, we are talking about code points. In Unicode, a code point is usually, but not always, a character. Code points can sometimes represent single characters, but can also represent formatting and other non-alphanumeric characters. For example, the character é can be the single character "e" that includes an acute accent (U+00E9), or it could be displayed as a single character but be composed of an "e" (U+0065) and a "combining" acute accent (U+0301). Visually, you cannot distinguish between the two. |
Parameters
Parameter | Type | Definition and Requirements |
---|---|---|
|
String |
The String to extract the substring from. |
|
Integer |
The index of the first character in When When |
|
Integer |
Optional - The number of characters to extract. When Since Go does not have function overloading or optional arguments, you
must use the function |
Examples
The following query 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.
[ 'CDE', 'BCDEFG', 'HIJK', 'IJ' ]
['CDE', 'BCDEFG', 'HIJK', 'IJ']
[CDE BCDEFG HIJK IJ]
Arr(StringV(CDE), StringV(BCDEFG), StringV(HIJK), StringV(IJ))
["CDE", "BCDEFG", "HIJK", "IJ"]
[ 'CDE', 'BCDEFG', 'HIJK', 'IJ' ]
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!