PostgreSQL String Functions

24 functions

CONCATCONCAT(str, ...)

Concatenates strings (ignoring NULLs).

CONCAT_WSCONCAT_WS(sep, str, ...)

Concatenates strings with a separator between each.

SUBSTRINGSUBSTRING(str FROM pos FOR len)

Extracts a substring by position and length.

LEFTLEFT(str, n)

Returns the leftmost n characters.

RIGHTRIGHT(str, n)

Returns the rightmost n characters.

LENGTHLENGTH(str)

Returns the character count of a string.

UPPERUPPER(str)

Converts a string to uppercase.

LOWERLOWER(str)

Converts a string to lowercase.

TRIMTRIM([{BOTH|LEADING|TRAILING} c FROM] str)

Removes leading and trailing spaces (or specified characters).

BTRIMBTRIM(str [, chars])

Removes specified characters from both ends of a string.

REPLACEREPLACE(str, from, to)

Replaces all occurrences of a substring.

POSITIONPOSITION(substr IN str)

Returns the position of a substring.

LPADLPAD(str, n, fill)

Left-pads a string to a specified length.

RPADRPAD(str, n, fill)

Right-pads a string to a specified length.

REPEATREPEAT(str, n)

Repeats a string n times.

REVERSEREVERSE(str)

Reverses a string.

SPLIT_PARTSPLIT_PART(str, delim, n)

Returns the nth part after splitting by a delimiter.

INITCAPINITCAP(str)

Converts the first letter of each word to uppercase.

TO_CHARTO_CHAR(value, format)

Converts a value to a formatted string.

REGEXP_REPLACEREGEXP_REPLACE(str, pat, rep [, flags])

Replaces matches of a regular expression pattern.

REGEXP_MATCHREGEXP_MATCH(str, pattern)

Returns an array of the first regex match.

STRING_AGGSTRING_AGG(expr, sep)

Concatenates strings with a separator (aggregate).

FORMATFORMAT(fmtstr, ...)

Returns a printf-style formatted string.

MD5MD5(str)

Returns the MD5 hash of the string.