user2545602
user2545602

Reputation: 31

Remove all the numeric characters in SQL Oracle

I want to remove all the numeric characters from a string in SQL, e.g. Från Japan samtal till 0046709757417

I want the output to be Från Japan samtal till

thanks.

Upvotes: 3

Views: 30417

Answers (2)

Gordon Linoff
Gordon Linoff

Reputation: 1271051

You can use the translate() function (see here):

select translate(col, 'a0123456789', 'a')

This function replaces the characters is in the first string with the corresponding characters in the second string. The 'a' is because of a peculiarity of Oracle. Oracle treats the empty string ('') as NULL, and translate() returns NULL if any of the arguments are NULL. The 'a' allows the second argument to have a value.

Here is a db<>fiddle.

Upvotes: 4

user330315
user330315

Reputation:

regexp_replace('Från Japan samtal till 0046709757417', '[0-9]', '')

SQLFiddle example: http://sqlfiddle.com/#!4/d41d8/24449

Upvotes: 5

Related Questions