Skip to content
Advertisement

Sql query for pattern matching on a keyword list with 2 character word

I have a predefined list of keywords , which I want to attach to a text during pattern matching.

For e.g :

Suppose the list of my keywords is : [‘DZ’ , ‘BL’ , ‘TS’ , ‘FZ’]

The characters that I will be attaching one of these keywords is ‘SN’

The text I am doing string matching in is : ‘RMK A02 SLP 29861 FZSNB24E36’

I want to extract strings which have any one keyword from the list + ‘SN’

Thanks in advance.Apologies for bad articulation. I am new to asking questions on Stack Overflow

Advertisement

Answer

You can list the allowed values in the regular expression:

select regexp_substr(col, '(DZ|BL|TS|FZ)SN'
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement