When querying a table containing phone numbers, I needed to keep only numeric characters, so I used the following to remove non-numeric characters.
select info original, regexp_replace(info, '[^0-9]', '', 'g') modified
from phone_numbers p
limit 10;
| Original | Modified |
|---|---|
| 692-185-2718 x98881 | 692185271898881 |
| (405) 246-1642 x2421 | 40524616422421 |
| 176.234.2623 | 1762342623 |
| 463-758-5197 x5394 | 46375851975394 |
| 855.864.7804 x1939 | 85586478041939 |
| 292-053-3547 x36563 | 292053354736563 |
| 1-484-900-3936 x511 | 14849003936511 |
| (746) 554-8818 x59882 | 746554881859882 |
| 1-384-559-3030 x3957 | 138455930303957 |
| 784.152.0155 | 7841520155 |