Text Functions

List of text functions

  • CONCAT

  • CONCAT_WS

  • LEN

  • UPPER_CASE

  • LOWER_CASE

  • LEFT

  • RIGHT

  • TRIM

  • TRIM_LEFT

  • TRIM_RIGHT

  • SUBSTR

  • RE

  • TEST

  • TEXT

  • MATCH

  • REPLACE

  • SPLIT

Deprecated functions

  • STRINGFORMAT

Concatenation (CONCAT)

Adds two or more strings together.

  • Takes at least 1 argument.

  • All arguments must be strings, numbers, variables or alternatively arrays.

Concatenation with a separator (CONCAT_WS)

Adds two or more strings together with a separator.

  • Takes at least 2 arguments.

  • The first argument specifies the separator.

  • The other arguments are the values to be concatenated.

  • The arguments have to be strings, numbers or variables.

  • All arguments except the first one can also take arrays.

Length (LEN)

Returns the length of a string.

  • Takes 1 argument.

  • The argument has to be a string, number, or a variable.

Upper case (UPPER_CASE)

Converts a string to the upper case.

  • Takes 1 argument.

  • The argument has to be a string or a variable.

Lower case (LOWER_CASE)

Converts a string to the lower case.

  • Takes 1 argument.

  • The argument has to be a string or a variable.

Left (LEFT)

Returns the first character of a string or the specified number of characters from the beginning.

  • Takes 1 or 2 arguments.

  • The first argument has to be a string, number or a variable.

  • The second optional argument specifies the number of characters to be taken from the left side. If not specified, it defaults to 1.

Right (RIGHT)

Returns the last character of a string or the specified number of characters from the end.

  • Takes 1 or 2 arguments.

  • The first argument has to be a string, number or a variable.

  • The second optional argument specifies the number of characters to be taken from the right side. If not specified, it defaults to 1.

Trim (TRIM)

Trims leading and trailing spaces in a string.

  • Takes 1 argument.

  • The argument has to be a string, number or a variable.

Trim left (TRIM_LEFT)

Trims leading spaces in a string.

  • Takes 1 argument.

  • The argument has to be a string, number or a variable.

Trim right (TRIM_RIGHT)

Trims trailing spaces in a string.

  • Takes 1 argument.

  • The argument has to be a string, number or a variable.

Substring (SUBSTR)

Returns a substring from a specified position of a string.

  • Takes 2 or 3 arguments.

  • The first argument has to be a string or a variable.

  • The second argument is the index of the first character to appear in the substring

  • The third, optional argument is the index of the last character to appear in the substring

  • The second and third argument has to be a number or a variable.

  • If the third argument is not provided, the substring spans till the end of the original string.

Regular expression (RE)

Builds a regular expression for use in other text functions (TEST, MATCH, REPLACE, SPLIT).

  • Takes 1 or 2 arguments.

  • The first argument is a string representation of the regular expression.

  • The second optional argument is a string representation of custom flags.

Test (TEST)

Tests a string for a match against a regular expression and returns true or false.

  • Takes 2 arguments.

  • The first argument specifies to string to be tested.

  • The first argument has to be a string, number or a variable.

  • The second argument specifies the substring whose presence is to be tested.

  • The second argument can take a string or the RE function.

Text (TEXT)

Returns the input exactly as it is, without evaluating variables or executing functions.

  • It outputs the raw form of whatever you pass in.

  • Takes 1 argument.

  • The argument can be string, number, date, array, object.

Match (MATCH)

Tests a string for a match against a regular expression and returns an array of matches (or null for no matches).

  • Takes 2 arguments.

  • The first argument specifies to string to be tested for matches.

  • The first argument has to be a string, number or a variable.

  • The second argument specifies the regular expression to be used for the matching.

  • The second argument can take a string or the RE function.

  • When the second argument is given as a plain string, the match is performed with the g (global) flag.

Replace (REPLACE)

Takes a string, matches it against a regular expression and replaces the matches with a given replacement string.

  • Takes 3 arguments.

  • The first argument specifies to string to be tested for matches.

  • The first argument has to be a string, number or a variable.

  • The second argument specifies the regular expression to be used for the matching.

  • The second argument can take a string or the RE function.

  • When the second argument is given as a plain string, the match is performed with the g (global) flag.

  • The third argument specifies the replacement string.

Argument 1 --> where to replace

Argument 2 --> what to replace

Argument 3 --> for what to replace

Split (SPLIT)

Takes a string, matches it against a regular expression and splits it into an array of strings.

  • Takes 2 arguments.

  • The first argument specifies to string to be tested for matches.

  • The first argument has to be a string, number or a variable.

  • The second argument specifies the regular expression to be used for the matching.

  • The second argument can take a string or the RE function.

  • When the second argument is given as a plain string, the match is performed with the g (global) flag.

String format (STRINGFORMAT) (deprecated)

Includes variables into a string.

  • Must have 1 argument, the string with variables to include.

Last updated