Re: String trim function - possible bug?

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Woody Woodring <george(dot)woodring(at)iglass(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: String trim function - possible bug?
Date: 2007-06-06 17:33:15
Message-ID: 20070606102643.H30214@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Wed, 6 Jun 2007, Woody Woodring wrote:

> I am seeing weirdness using the trim function on a string:
>
> This works as expected:
>
> SELECT 'dhct:bn', trim(leading 'dhct:' from 'dhct:bn');
> ?column? | ltrim
> ----------+-------
> dhct:bn | bn
> (1 row)
>
> However it fails for these cases:
>
> SELECT 'dhct:dn', trim(leading 'dhct:' from 'dhct:dn');
> ?column? | ltrim
> ----------+-------
> dhct:dn | n
> (1 row)

The 8.2 docs give this as the description in the table:
"Remove the longest string containing only the characters (a space by
default) from the start/end/both ends of the string"

That implies that with characters 'dhct:' the string to remove is 'dhct:d'
because that's the longest leading string made up of those characters.

Maybe a form using something like regexp_replace might work better for
you.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Woody Woodring 2007-06-06 18:07:31 Re: String trim function - possible bug?
Previous Message Martijn van Oosterhout 2007-06-06 16:50:14 Re: String trim function - possible bug?