Reputation: 197
I have two string like this and I want to extract 6 digits starting from "2007" using postgresql. Please help
"472a62b98b-2004-07-l-de_k-de_n-email_t-cus_200703"
"21d6bd96f2-2004-04-l-de_c-de_m-email_t-cus_200705-b"
Results would be:
"200703"
"200705"
Upvotes: 0
Views: 39
Reputation:
You can use substring()
with a regex:
substring(the_column from '2007[0-9]{2}')
This extracts the first substring that starts with 2007
and is followed by (exactly) two digits.
Upvotes: 1