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

From Woody Woodring
Subject Re: String trim function - possible bug?
Date
Msg-id 098c01c7a865$8d20d190$80b1a8c0@istructure.com
Whole thread Raw
In response to Re: String trim function - possible bug?  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
List pgsql-general
My fault, I apologize.  I did realize my mistake while I was at lunch but
had responses before I could post to fix my error.  I can use the
"replace()" function instead.

Thanks,
Woody

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] On Behalf Of Stephan Szabo
Sent: Wednesday, June 06, 2007 1:33 PM
To: Woody Woodring
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] String trim function - possible bug?


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.

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@postgresql.org so that your
       message can get through to the mailing list cleanly


pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: String trim function - possible bug?
Next
From: David Gardner
Date:
Subject: Re: pl/pgsql debuging, was Re: debugging C functions