mercredi 21 juin 2023

Find Specific Pattern in String via SQL

I have a column of what we'll call remarks. Basically notes. I want to see if I can extract exact patterns of alpha or numbers from these notes see example.

 REMARKS                           
 'This is the magic key 24HMBC123456 dont lose it ex644' 
 'Code 31hbxx123456 is tested good px543' 
 'rt445 has tested 61CGRW123456 as good jx163'

for the above column I'd test and extract for a pattern of 2 numbers followed by 4 alphas followed by 6 numbers. but I dont know how to code that to get just:

    24HMBC123456
    31hbxx123456
    61CGRW123456 

Any help is appreciated.

I thought to use a case when REGEXP_INSTR mixed with some substrings but this appears either Im over complicating it or its really that complicated.

Aucun commentaire:

Enregistrer un commentaire