Search code examples
regexteradataregexp-replace

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. "johnsmith@gmail.com,","). I want to replace all commas and double quotes with a space.

What is the correct syntax in teradata?


Solution

  • 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
    )