Skip site navigation (1) Skip section navigation (2)

Re: trim(both) problem?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Fernando Hevia" <fhevia(at)ip-tel(dot)com(dot)ar>
Cc: "'Emi Lu'" <emilu(at)encs(dot)concordia(dot)ca>, pgsql-sql(at)postgresql(dot)org
Subject: Re: trim(both) problem?
Date: 2008-04-25 21:26:27
Message-ID: 751.1209158787@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-sql
"Fernando Hevia" <fhevia(at)ip-tel(dot)com(dot)ar> writes:
>> Trim doesn't do what you think it does. The '<BR/>' 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('<BR/>ROI Engineering Inc.', '<BR/>', '')

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('<BR/>ROI Engineering Inc.', '^<BR/>', '');
select regexp_replace('ROI Engineering Inc.<BR/>', '<BR/>$', '');

			regards, tom lane

In response to

Responses

pgsql-sql by date

Next:From: chester c youngDate: 2008-04-25 21:48:26
Subject: Re: trim(both) problem?
Previous:From: Fernando HeviaDate: 2008-04-25 21:03:14
Subject: Re: trim(both) problem?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group