What are some common string functions in PostgreSQL?

Answer

PostgreSQL has rich string functions: LENGTH(str) / CHAR_LENGTH(str) (length in characters), UPPER(str) / LOWER(str), TRIM(str) / LTRIM / RTRIM (remove whitespace), SUBSTRING(str FROM pos FOR len) or SUBSTR(str, pos, len), POSITION(substr IN str) (find position), REPLACE(str, from, to), CONCAT(str1, str2, ...) or the || operator, LPAD(str, len, fill) / RPAD (pad string), SPLIT_PART(str, delimiter, n) (split and pick part), REGEXP_REPLACE(str, pattern, replacement), REGEXP_MATCH(str, pattern), INITCAP(str) (title case), MD5(str) (hash), FORMAT('Hello %s, you are %s years old', name, age).