> Full Neon documentation index: https://neon.com/docs/llms.txt

# PostgreSQL String Functions

This page provides the most commonly used PostgreSQL string functions that allow you to manipulate string data effectively.

| Function                                                                                             | Description                                                                                             | Example                                             | Result             |
| ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------- | ------------------ |
| [ASCII](https://neon.com/postgresql/postgresql-string-functions/postgresql-ascii)                    | Return the ASCII code value of a character or Unicode code point of a UTF8 character                    | ASCII('A')                                          | 65                 |
| [CHR](https://neon.com/postgresql/postgresql-string-functions/postgresql-chr)                        | Convert an ASCII code to a character or a Unicode code point to a UTF8 character                        | CHR(65)                                             | 'A'                |
| [CONCAT](https://neon.com/postgresql/postgresql-string-functions/postgresql-concat-function)         | Concatenate two or more strings into one                                                                | CONCAT('A','B','C')                                 | 'ABC'              |
| [CONCAT\_WS](https://neon.com/postgresql/postgresql-string-functions/postgresql-concat_ws)           | Concatenate strings with a specified separator.                                                         | CONCAT\_WS(',','A','B','C')                         | 'A,B,C'            |
| [FORMAT](https://neon.com/postgresql/postgresql-string-functions/postgresql-format)                  | Format a string based on a template                                                                     | FORMAT('Hello %s','PostgreSQL')                     | 'Hello PostgreSQL' |
| [INITCAP](https://neon.com/postgresql/postgresql-string-functions/postgresql-initcap)                | Convert words in a string to title case                                                                 | INITCAP('hI tHERE')                                 | Hi There           |
| [LEFT](https://neon.com/postgresql/postgresql-string-functions/postgresql-left)                      | Return the first n character in a string                                                                | LEFT('ABC',1)                                       | 'A'                |
| [LENGTH](https://neon.com/postgresql/postgresql-string-functions/postgresql-length-function)         | Return the number of characters in a string                                                             | LENGTH('ABC')                                       | 3                  |
| [LOWER](https://neon.com/postgresql/postgresql-string-functions/postgresql-lower)                    | Convert a string to lowercase                                                                           | LOWER('hI tHERE')                                   | 'hi there'         |
| [LPAD](https://neon.com/postgresql/postgresql-string-functions/postgresql-lpad)                      | Extending a string to a length by padding specified characters on the left                              | LPAD('123', 5, '00')                                | '00123'            |
| [LTRIM](https://neon.com/postgresql/postgresql-string-functions/postgresql-ltrim)                    | Remove the longest string that contains specified characters from the left of the input string          | LTRIM('00123')                                      | '123'              |
| [MD5](https://neon.com/postgresql/postgresql-string-functions/postgresql-md5)                        | Return MD5 hash of a string in hexadecimal                                                              | MD5('ABC')                                          |                    |
| [POSITION](https://neon.com/postgresql/postgresql-string-functions/postgresql-position)              | Return the location of a substring in a string                                                          | POSITION('B' in 'A B C')                            | 3                  |
| [REGEXP\_MATCHES](https://neon.com/postgresql/postgresql-string-functions/postgresql-regexp_matches) | Replace substrings that match a POSIX regular expression with a new substring                           | SELECT REGEXP\_MATCHES('ABC', '^(A)(..)$', 'g');    | \{A,BC}            |
| [REGEXP\_REPLACE](https://neon.com/postgresql/postgresql-string-functions/regexp_replace)            | Replace a substring using regular expressions.                                                          | REGEXP\_REPLACE('John Doe','(.\*) (.\*)','\2, \1'); | 'Doe, John'        |
| [REPEAT](https://neon.com/postgresql/postgresql-string-functions/postgresql-repeat)                  | Repeat a string the specified number of times.                                                          | REPEAT('\*', 5)                                     | '\*\*\*\*\*'       |
| [REPLACE](https://neon.com/postgresql/postgresql-string-functions/postgresql-replace)                | Replace a substring within a string with a new one.                                                     | REPLACE('ABC','B','A')                              | 'AAC'              |
| [REVERSE](https://neon.com/postgresql/postgresql-string-functions/postgresql-reverse)                | Replace a substring within a string with a new one                                                      | REVERSE('ABC')                                      | 'CBA'              |
| [RIGHT](https://neon.com/postgresql/postgresql-string-functions/postgresql-right)                    | Return the last n characters in the string. When n is negative, return all but the first \n characters. | RIGHT('ABC', 2)                                     | 'BC'               |
| [RPAD](https://neon.com/postgresql/postgresql-string-functions/postgresql-rpad)                      | Extend a string to a length by appending specified characters.                                          | RPAD('ABC', 6, 'xo')                                | 'ABCxox'           |
| [RTRIM](https://neon.com/postgresql/postgresql-string-functions/postgresql-rtrim)                    | Remove the longest string that contains specified characters from the right of the input string         | RTRIM('abcxxzx', 'xyz')                             | 'abc'              |
| [SPLIT\_PART](https://neon.com/postgresql/postgresql-string-functions/postgresql-split_part)         | Split a string on a specified delimiter and return nth substring                                        | SPLIT\_PART('2017-12-31','-',2)                     | '12'               |
| [SUBSTRING](https://neon.com/postgresql/postgresql-string-functions/postgresql-substring)            | Extract a substring from a string                                                                       | SUBSTRING('ABC',1,1)                                | A'                 |
| [TRIM](https://neon.com/postgresql/postgresql-string-functions/postgresql-trim-function)             | Remove the leading and trailing characters from a string.                                               | TRIM(' ABC  ')                                      | 'ABC'              |
| [UPPER](https://neon.com/postgresql/postgresql-string-functions/postgresql-upper)                    | Convert a string to uppercase                                                                           | UPPER('hI tHERE')                                   | 'HI THERE'         |
