Re: String trim function - possible bug?

From: "Woody Woodring" <george(dot)woodring(at)iglass(dot)net>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: String trim function - possible bug?
Date: 2007-06-06 18:07:31
Message-ID: 098c01c7a865$8d20d190$80b1a8c0@istructure.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Stephan Szabo
Sent: Wednesday, June 06, 2007 1:33 PM
To: Woody Woodring
Cc: pgsql-general(at)postgresql(dot)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(at)postgresql(dot)org so that your
message can get through to the mailing list cleanly

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Gardner 2007-06-06 18:18:43 Re: pl/pgsql debuging, was Re: debugging C functions
Previous Message Stephan Szabo 2007-06-06 17:33:15 Re: String trim function - possible bug?