Keerthi
Keerthi

Reputation: 3

Query to replace special characters in phone number field

Can anyone help with a query on how to replace special/non-numeric/hidden characters from a phone number column.

I've tried

LTRIM(RTRIM(REGEXP_REPLACE(
          PHONE_NBR,
          '[^[:digit:]][:cntrl:][:alpha:][:graph:][:blank:][:print:][:punct:][:space:]~',
          '')))

but no luck, there are still a few records which contain non-numeric values.

Upvotes: 0

Views: 1082

Answers (1)

kfinity
kfinity

Reputation: 9091

Your regex is saying to ONLY replace a string consisting of: a non-numeric character followed by a control character, an alpha, a graph, a blank, a print, a punct, a space, and then a tilde.

You should be able to just use '[^[:digit:]]' as your regex, to remove all non-numeric characters.

Upvotes: 1

Related Questions