We're Moving!

The Vertica Forum is moving to a new OpenText Analytics Database (Vertica) Community.

Join us there to post discussion topics, learn about

product releases, share tips, access the blog, and much more.

Create My New Community Account Now


Extract Just Numbers from a String of Characters — Vertica Forum

Extract Just Numbers from a String of Characters

Jim Knicely authored this tip.

The easiest way to extract just the numbers from a string of characters is to simply remove any character that isn’t a number!

Example:

dbadmin=> SELECT c1, regexp_replace(c1, '\D', '') FROM bunch_of_characters;
       c1        | regexp_replace
-----------------+----------------
 A1B2C3D4E5      | 12345
 ABCDE12345      | 12345
 Phone: 555-0100 | 5550100
 1!2$3%4^5       | 12345
(4 rows)

Have Fun!

Sign In or Register to comment.