In postgresql, I need to extract 3 specific alphanumeric characters from a field for a given column and then create the year from it. So if the value of the field is FUT,GRA,S12,1055559
or S11,1050830,PON
, I need S11
or S12
and then to create 2011
or 2012
.
The Result can remain a text field.
I have used the following to get the S??
out: substring(my_field from E'(S\\d\\d),')
but creating the year seems to be more challenging. I was hoping to use regexp_split_to_array
but it does not seem to be working very well.