Didn't correct output for LTRIM function

Started by PG Bug reporting formalmost 4 years ago3 messagesdocs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/14/bug-reporting.html
Description:

First check the output of "select LTRIM(' startech academy ', ' sta');"
output is "rtech academy "
now the thing is output of "select LTRIM(' startech academy ', ' star');"
output is "ech academy "
the question is where is 't'?

The problem is when we do LTRIM for trimming the first four characters, it
trims the first five characters. but in the case of doing three characters,
it gives the correct output.

#2Guillaume Lelarge
guillaume@lelarge.info
In reply to: PG Bug reporting form (#1)
Re: Didn't correct output for LTRIM function

Le lun. 13 juin 2022 à 10:06, PG Doc comments form <noreply@postgresql.org>
a écrit :

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/14/bug-reporting.html
Description:

First check the output of "select LTRIM(' startech academy ', ' sta');"

output is "rtech academy "
now the thing is output of "select LTRIM(' startech academy ', '
star');"
output is "ech academy "
the question is where is 't'?

It's trimmed, because you asked t to be removed. It trims every single
character at the beginning of the string till it encounters another
character. The doc example makes it more clear:

ltrim('zzzytest', 'xyz') → test

https://www.postgresql.org/docs/14/functions-string.html

The problem is when we do LTRIM for trimming the first four characters, it

trims the first five characters. but in the case of doing three characters,
it gives the correct output.

Both outputs are correct actually.

--
Guillaume.

#3nikunj vadsak
nikunjkvadsakabcd@gmail.com
In reply to: Guillaume Lelarge (#2)
Re: Didn't correct output for LTRIM function

Thank you for the clarification.

On Mon, 13 Jun 2022, 4:27 am Guillaume Lelarge, <guillaume@lelarge.info>
wrote:

Show quoted text

Le lun. 13 juin 2022 à 10:06, PG Doc comments form <noreply@postgresql.org>
a écrit :

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/14/bug-reporting.html
Description:

First check the output of "select LTRIM(' startech academy ', '
sta');"
output is "rtech academy "
now the thing is output of "select LTRIM(' startech academy ', '
star');"
output is "ech academy "
the question is where is 't'?

It's trimmed, because you asked t to be removed. It trims every single
character at the beginning of the string till it encounters another
character. The doc example makes it more clear:

ltrim('zzzytest', 'xyz') → test

https://www.postgresql.org/docs/14/functions-string.html

The problem is when we do LTRIM for trimming the first four characters, it

trims the first five characters. but in the case of doing three
characters,
it gives the correct output.

Both outputs are correct actually.

--
Guillaume.