-1

@All - Thanks for your help

ID Email

1 [email protected]. , [email protected]@

2 [email protected]

In the above example, if you see the 1st row, the email address is invalid because of dot at the end of 1st email address and @ at the end of 2nd email address. In 2nd row, there is a ? in between email address.

Just wanted to know is there any way to handle there characters and remove those from email address using SQL function and update the same in table.

Thanks in advance.

3
  • please provide an example with desired result Commented Jan 29, 2020 at 8:46
  • 1
    Does this answer your question? Multiple REPLACE function in Oracle Commented Jan 29, 2020 at 8:50
  • if you are looking for a function removeAllWrongCharacters. then there is no such function. you already have to make specifications, e.g. which characters and where they have to be removed. in your case you have to work with regular expressions Commented Jan 29, 2020 at 17:46

3 Answers 3

2

you can also check a translate function

translate('my ,string@with .special chars','@,?. ', ' ')
Sign up to request clarification or add additional context in comments.

1 Comment

@karthiksanu . . . I fixed a typo in the answer and this is the best answer. translate() does exactly what you are asking for, if you have a specific list of characters you want to replace.
1

You could nest multiple invokations of replace(), but this quickly becomes convoluted.

On the other hand, regexp_replace() comes handy for this:

regexp_replace(column_name, '@|,|\?|\.', ' ')

The pipe character (|) stands for or. The dot (.) and the question mark (?) are meaningful characters in regexes so they need to escaped with a backslash (\).

Comments

1

Something like this will "remove" everything but digits, letters and spaces (if that's what you wanted).

SQL> with test (col) as
  2    (select 'This) is a se#nten$ce with. everything "but/ only 123 numbers, and ABC lett%ers' from dual)
  3  select regexp_replace(col, '[^a-zA-Z0-9 ]') result
  4  from test;

RESULT
-----------------------------------------------------------------------
This is a sentence with everything but only 123 numbers and ABC letters

SQL>

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.