Extract only numbers from a varchar column

From: "Leandro Casadei" <mateamargo(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Extract only numbers from a varchar column
Date: 2008-05-05 17:08:55
Message-ID: 5983afbb0805051008t2c714837y1052d11273b3529f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I need to extract only the first occurence of numbers from a column that is
varchar.

Here are a few examples of what I need to do:

abc200xx -> 200
340ppsdd -> 340
150ytyty555 -> 150

Can this be done by a simple query or do I need to use a cursor?

Thanks

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-05-05 17:36:01 Re: operator varchar = integer
Previous Message Daniel Schuchardt 2008-05-05 16:53:20 Re: operator varchar = integer