Built-in string functions¶
NebulaGraph supports the following built-in string functions:
Note
Like SQL, the position index of nGQL starts from 1, while in C language it starts from 0.
| Function | Description |
|---|---|
| int strcasecmp(string a, string b) | Compares string a and b without case sensitivity. When a = b, the return value is 0. When a > b, the return value is greater than 0. When a < b, the return value is less than 0. |
| string lower(string a) | Returns the argument in lowercase. |
| string toLower(string a) | The same as lower(). |
| string upper(string a) | Returns the argument in uppercase. |
| string toUpper(string a) | The same as upper(). |
| int length(string a) | Returns the length of the given string in bytes. |
| string trim(string a) | Removes leading and trailing spaces. |
| string ltrim(string a) | Removes leading spaces. |
| string rtrim(string a) | Removes trailing spaces. |
| string left(string a, int count) | Returns a substring consisting of count characters from the left side of string a. If string a is shorter than count, the system returns string a. |
| string right(string a, int count) | Returns a substring consisting of count characters from the right side of string a. If string a is shorter than count, the system returns string a. |
| string lpad(string a, int size, string letters) | Left-pads string a with string letters and returns a substring with the length of size. |
| string rpad(string a, int size, string letters) | Right-pads string a with string letters and returns a substring with the length of size. |
| string substr(string a, int pos, int count) | Returns a substring extracting count characters starting from the specified position pos of string a. |
| string substring(string a, int pos, int count) | The same as substr(). |
| string reverse(string) | Returns a string in reverse order. |
| string replace(string a, string b, string c) | Replaces string b in string a with string c. |
| list split(string a, string b) | Splits string a at string b and returns a list of strings. |
| string toString() | Takes in any data type and converts it into a string. |
| int hash() | Takes in any data type and encodes it into a hash value. |
Note
If the argument is NULL, the return is undefined.
Explanations for the return of substr() and substring()¶
- The position index starts from
0.
- If
posis 0, the whole string is returned.
- If
posis greater than the maximum string index, an empty string is returned.
- If
posis a negative number,BAD_DATAis returned.
- If
countis omitted, the function returns the substring starting at the position given byposand extending to the end of the string.
- If
countis 0, an empty string is returned.
- Using
NULLas any of the argument ofsubstr()will cause an issue.
OpenCypher compatibility
- In openCypher, if
aisnull,nullis returned. - In openCypher, if
posis 0, the returned substring starts from the first character, and extend tocountcharacters. - In openCypher, if either
posorcountisnullor a negative integer, an issue is raised.
Last update:
March 13, 2023