Search code examples
oracleoracle11g

Remove Email Ids from a Strings


I have a string with multiple email and need to only remove the email address from the string. Tried using the regexp but not exactly sure how to keep the other text but only remove the emails

David Ram:[email protected],Seja:[email protected],Yogan:[email protected]

Query:

 SELECT REGEXP_REPLACE(TEXTAREA,':[a-zA-z0-9.]@[a-zA-z0-9.]*' )  FROM CONTEXT  

Output:

David Ram,Seja,Yogan

Solution

  • Here's one option:

    SQL> with test(col) as
      2    (select 'David Ram:[email protected],Seja:[email protected],Yogan:[email protected]' from dual)
      3  select regexp_replace(col, ':\w+@\w+\.\w+') result
      4  from test;
    
    RESULT
    --------------------
    David Ram,Seja,Yogan
    
    SQL>