Thread: Is there a function which eliminates spaces?

Is there a function which eliminates spaces?

From
Pierre Couderc
Date:
In a WHERE clause, I want to to compare strings ignoring the spaces
inside them. Is there a function to do that? I do not find it in the
documentation.

SELECT (...) WHERE (ignore_spaces(table.phone_number) ~* igore_spaces(?));

would be fine but ignore_space() does not exist!

Maybe there is a solution based on regular expression, but I do not see it.

Re: Is there a function which eliminates spaces?

From
Michael Glaesemann
Date:
On Oct 24, 2005, at 22:24 , Pierre Couderc wrote:

> SELECT (...) WHERE (ignore_spaces(table.phone_number) ~*
> igore_spaces(?));
>
> would be fine but ignore_space() does not exist!

Take a look at translate() or replace(). They may do what you want.

http://www.postgresql.org/docs/8.0/interactive/functions-string.html

test=# select translate('foo  foo', ' ', '') = translate('foo foo
', ' ', '');
?column?
----------
t
(1 row)

Hope this helps.

Michael Glaesemann
grzm myrealbox com