On our series of discussing functions in age.
In this article we will be discussing the second half of string functions in age. These functions can be used to manipulate the strings in some way. You can also visit the first part over here:
part1
lTrim:
The method returns the original string with removed white spaces.
Syntax:
lTrim(originalString)
- originalString is the string on which the operation will be performed.
Returns:
A String.
Sample Query:
SELECT *
FROM cypher('your_graph_name', $$
RETURN lTrim(' Talha ')
$$) as (trimmedString agtype);
The above query will trim the left most white spaces and will print "Talha " on the screen.
Trim:
The method returns the original string with all the white spaces removed either they be leading or trailing.
Syntax:
trim(originalString)
- originalString is the string on which the operation will be performed.
Returns:
A String.
Sample Query:
SELECT *
FROM cypher('your_graph_name', $$
RETURN trim(' Talha ')
$$) as (trimmedString agtype);
The above query will remove all the white spaces in the string and return the string "Talha".
ToLower:
The method returns the lowercase version of original string.
Syntax:
toLower(originalString)
- originalString is the string on which the operation will be performed.
Returns:
A String.
Sample Query:
SELECT *
FROM cypher('your_graph_name', $$
RETURN toLower('TALHA')
$$) as (lowerString agtype);
The above query will return the lowercase version of TALHA i.e. "talha"(Final string returned.)
ToUpper:
The method returns the original string in uppercase
Syntax:
toUpper(originalString)
- originalString is the string on which the operation will be performed.
Returns:
A String.
Sample Query:
SELECT *
FROM cypher('your_graph_name', $$
RETURN toUpper('talha')
$$) as (upperString agtype);
The above query will return the uppercase version of the string. i.e. "TALHA"
Reverse:
The method returns the reversed version of the string, i.e. the order of characters are reversed.
Syntax:
reverse(originalString)
- originalString is the string on which the operation will be performed.
Returns:
A String.
Sample Query:
SELECT *
FROM cypher('your_graph_name', $$
RETURN reverse("everytime")
$$) as (reversedString agtype);
The above query will reverse the order of characters in the string and will return "emityreve".
toString:
The method converts an integer, float or boolean value to a string value.
Syntax:
toString(An expression)
- Expression can be a integer, float or a boolean value or an expression that converts to a integer, float or a boolean.
Returns:
A String.
Sample Query:
SELECT *
FROM cypher('your_graph_name', $$
RETURN toString(99), toString('a string'), toString(true)
$$) as (floatToString agtype, str_to_str agtype, boolToString);
The above query will return 3 strings "99", "a string", "true".
References:
You can view more on GitHub and documentation of Apache age by following these links:
Top comments (0)