PostgreSQL substring get string between brackets

后端 未结 2 1197
北恋
北恋 2021-01-17 12:12

I have a string, say:

Product Description [White]

I want to extract anything inside the brackets (in this case White) from that str

相关标签:
2条回答
  • 2021-01-17 12:40

    i think you want to update some value like grade pay from pay scale or any thing just use following query

    UPDATE master.pay_scale SET grade_pay= Case When description LIKE '%(%)%' Then (select substring(description from '((.+))')) else description End::numeric

    0 讨论(0)
  • 2021-01-17 12:48

    (.) only matches a single character, but you want to match multiple characters in there.

    So you need (.+)

    substring('Product Description [White]' from '\[(.+)\]')
    
    0 讨论(0)
提交回复
热议问题