Re: [SQL] trim(both) problem?

2008-04-25 Thread chester c young
--- Emi Lu <[EMAIL PROTECTED]> wrote:
 
> Isn't this a bug about trim both.
> 
>   select trim(both '' from 'ROI Engineering Inc.');
>  btrim
> -
>   OI Engineering Inc.
> (1 row)
> 
> 
> "R" is missing? How?

you misread - '' argument is a list of characters, _not_ a string.
 change 'ROI' to 'XOI' and you'll see.


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] trim(both) problem?

2008-04-25 Thread Tom Lane
"Fernando Hevia" <[EMAIL PROTECTED]> writes:
>> Trim doesn't do what you think it does. The '' in the 
>> above is not a string to remove it is a list of characters to 
>> remove.  Thus, the R is removed as it matches a character given.

> You could probably use instead:

> select replace('ROI Engineering Inc.', '', '')

That would zap occurrences in the middle of the string, though.
regexp_replace would be better since it'd allow anchoring the
pattern, eg

select regexp_replace('ROI Engineering Inc.', '^', '');
select regexp_replace('ROI Engineering Inc.', '$', '');

regards, tom lane

-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] trim(both) problem?

2008-04-25 Thread Fernando Hevia
 

> -Mensaje original-
> De: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] En nombre de Stephan Szabo
> Enviado el: Viernes, 25 de Abril de 2008 17:46
> Para: Emi Lu
> CC: pgsql-sql@postgresql.org
> Asunto: Re: [SQL] trim(both) problem?
> 
> On Fri, 25 Apr 2008, Emi Lu wrote:
> 
> > Hi,
> >
> > Isn't this a bug about trim both.
> >
> >   select trim(both '' from 'ROI Engineering Inc.');
> >  btrim
> > -
> >   OI Engineering Inc.
> > (1 row)
> >
> >
> > "R" is missing? How?
> 
> Trim doesn't do what you think it does. The '' in the 
> above is not a string to remove it is a list of characters to 
> remove.  Thus, the R is removed as it matches a character given.
> 

You could probably use instead:

select replace('ROI Engineering Inc.', '', '')



-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] trim(both) problem?

2008-04-25 Thread Stephan Szabo
On Fri, 25 Apr 2008, Emi Lu wrote:

> Hi,
>
> Isn't this a bug about trim both.
>
>   select trim(both '' from 'ROI Engineering Inc.');
>  btrim
> -
>   OI Engineering Inc.
> (1 row)
>
>
> "R" is missing? How?

Trim doesn't do what you think it does. The '' in the above is not a
string to remove it is a list of characters to remove.  Thus, the R is
removed as it matches a character given.



-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] trim(both) problem?

2008-04-25 Thread Tom Lane
Emi Lu <[EMAIL PROTECTED]> writes:
>   select trim(both '' from 'ROI Engineering Inc.');
>  btrim
> -
>   OI Engineering Inc.
> (1 row)

> "R" is missing? How?

The first argument of trim is a set, not a sequence --- it means trim
any characters belonging to this set.

regards, tom lane

-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


[SQL] trim(both) problem?

2008-04-25 Thread Emi Lu

Hi,

Isn't this a bug about trim both.

 select trim(both '' from 'ROI Engineering Inc.');
btrim
-
 OI Engineering Inc.
(1 row)


"R" is missing? How?


 version
-
 PostgreSQL 8.0.15 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.2

Thank you!







--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql