I have a line, say:
Product Description [White]
I want to extract something inside the brackets (in this case White) from this line using the PostgreSQL substring function. I can get this to work with regexp_matches, but it returns an array that I don't want if I have no other choice.
I tried:
substring('string' from '[(.)]') →> NULLsubstring('string' from '\[(.)\]') →> NULLsubstring('string' from '\\[(.)\\]') →> NULL
But it works:
substring('string' from 'W(.)i]') →> h
What am I doing wrong?
source
share