Teradata regexp_replace to eliminate specific special characters

Christine Kang picture Christine Kang · Apr 13, 2015 · Viewed 18.3k times · Source

I imported a file that contains email addresses (email_source). I need to join this table to another, using this field but it contains commas (,) and double quotes (") before and after the email address (eg. "[email protected],","). I want to replace all commas and double quotes with a space.

What is the correct syntax in teradata?

Answer

Brian Stephens picture Brian Stephens · Apr 13, 2015

Just do this:

REGEXP_REPLACE(email_source, '[,"]', ' ',1,0,i)

Breakdown:

REGEXP_REPLACE(email_source, -- sourcestring
'[,"]', -- regexp
' ', --replacestring
1, --startposition
0, -- occurrence, 0 = all
'i' -- match -> case insensitive
)