PostgreSQL LTRIM() function

LTRIM() function

The PostgreSQL ltrim() function is used to remove spaces ( if no character(s) is provided as trimming_text ) or set of characters which are matching with the trimming_text, from the start of a string.

Syntax:

ltrim(<string>[, <triming_text>])

PostgreSQL Version: 9.3

Pictorial Presentation of PostgreSQL LTRIM() function

Example: PostgreSQL ltrim() function:

In the example below, the statement returns the result 'ltrim'. Here in the example the trimming_text is provided, and it is 'best', and the left four characters i.e. 'test' have removed and the characters 't' and 'e' and 's' are present in the trimming_text 'best'.

Code:

SELECT ltrim('testltrim', 'best');

Sample Output:

ltrim
-------
ltrim
(1 row)

Example of PostgreSQL ltrim() function with no text:

In the example below, the trimming_text is not provided, so by default the white spaces from the left side of the given string will be removed.