Re: String trim function - possible bug? - Mailing list pgsql-general

From Stephan Szabo
Subject Re: String trim function - possible bug?
Date
Msg-id 20070606102643.H30214@megazone.bigpanda.com
Whole thread Raw
In response to String trim function - possible bug?  ("Woody Woodring" <george.woodring@iglass.net>)
Responses Re: String trim function - possible bug?  ("Woody Woodring" <george.woodring@iglass.net>)
List 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.

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: String trim function - possible bug?
Next
From: "Woody Woodring"
Date:
Subject: Re: String trim function - possible bug?