Re: How to search ignoring spaces and minus signs - Mailing list pgsql-general

From Osvaldo Kussama
Subject Re: How to search ignoring spaces and minus signs
Date
Msg-id AANLkTim55pwH07Axsz2W_02NMbh-PGisB5JLxXgW-FwN@mail.gmail.com
Whole thread Raw
In response to How to search ignoring spaces and minus signs  ("Andrus" <kobruleht2@hot.ee>)
List pgsql-general
2010/10/13 Andrus <kobruleht2@hot.ee>:
> CHAR(20) columns in 8.4 database may contains spaces and - signs like
>
> 13-333-333
> 12 3-44
> 33 33 333
> 12345
>
> User enters code to search without spaces and - signs, like 12344
> How to search for product code ignoring spaces and - signs?
>
> For example searching for code 12344 should return
> 12 3-44  as matching item.
>


Try:
SELECT * FROM your_table WHERE regexp_replace(your_col,
'[^[:digit:]]', '', 'g') = your_number;

Osvaldo

pgsql-general by date:

Previous
From: Grzegorz Jaśkiewicz
Date:
Subject: Re: How to search ignoring spaces and minus signs
Next
From: Raymond O'Donnell
Date:
Subject: Re: Adding a New Column Specifically In a Table