Skip to content
Advertisement

Redshift regex for before and after certain char

Data :- 1,2,3=20,4,5

select regexp_substr(data,',3=[^,]*')

output = ,3=20

Desired output = 20

How do I get rid of,3=? I can add split_part(regexp_substr(Data,',713=[^,]*'),'=',2) but using the same expression would make sense.

Thanks

Advertisement

Answer

You can extract a pattern using a subexpression:

select regexp_substr(data, ',3=([^,]*)', 1, 1, 'e')
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement