Christine Kang
Christine Kang

Reputation: 45

Teradata regexp_replace to eliminate specific special characters

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?

Upvotes: 2

Views: 24973

Answers (2)

dnoeth
dnoeth

Reputation: 60472

You don't need a regex for this, a simple oTranslate should be more efficient:

oTranslate(email_source, ',"', '  ') 

Upvotes: 5

Brian Stephens
Brian Stephens

Reputation: 5271

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
)

Upvotes: 7

Related Questions