Search code examples
sqlregexteradatacontains

sql teradata regex contains pattern matching


I have a column like below in teradata. I want to extract all rows where just 'FEMA' is present. I dont want to find words that contain fema at start, or in middle or at the end. Generally in python I would do such search using \bfema\b. How could I achieve same results in teradata. I am thinking of something like where Col1 contains ('\bfema\b')

Col1 females are important and the rule is called FEMA


Solution

  • You can use regexp_instr here:

    select
    *
    from
    <your table>
    where
    regexp_instr(<your column>,'\bFEMA\b') > 0
    

    If you aren't concerned about case sensitivity, you can use regexp_instr(upper(<your column>),'\bFEMA\b') > 0