Please take this survey to help us learn more about how you use third party tools. Your input is greatly appreciated!

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!


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.

Can't find what you're looking for? Search the Vertica Documentation, Knowledge Base, or Blog for more information.