2

I have a column in a datawarehouse task which needs replacing these characters: "ABCDEFGHIJKLMNOPQRSTUVWXYZ\abcdefghijklmnopqrstuvwxyz" with nothing.

For example I have this form of data "88k77.22" and it should be "8877.22"

Does anyone know any particular function which can do this, or any workaround.

Thanks in advance

3
  • 2
    Replace and Regex_replace Commented Dec 7, 2018 at 10:19
  • Replace with nothing, not with space... ? Commented Dec 7, 2018 at 10:19
  • @HoneyBadger sorry, miss typo! I've edited it now Commented Dec 7, 2018 at 12:06

2 Answers 2

6

Use a regular expression

REGEXP_REPLACE(column, '[A-Za-z]*', '')

Is '\' supposed to be included as well? Then use

 REGEXP_REPLACE(column, '[A-Za-z\]*', '')
Sign up to request clarification or add additional context in comments.

2 Comments

\ is an escape character and it needs double slash to be escaped right?
@Simonare, not when it is inside a pair of brackets. \s matches whitespace but [\s] matches characters 's' and '\'
3

Oracle supports translate(), which does exactly what you want:

translate(col, ' ABCDEFGHIJKLMNOPQRSTUVWXYZ\abcdefghijklmnopqrstuvwxyz', ' ')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.