如何根据模式从postgresql中的列中提取子字符串?
RESULTS
--------------------------------------------
{"searchtext":"apple","Source":null,"User":null}
{"searchtext":"banana","Source":null,"User":null}
{"searchtext":"mango","Source":null,"User":null}
所需的输出是:
FINAL_RESULT
--------------------------------------------
apple
banana
mango
这是我写的,它不起作用:
select substring(af.RESULTS from '{"searchtext":"(.)","Source":null,"User":null}') as FINAL_RESULT from table af;
答案 0 :(得分:0)
想出来。我错过了'+'字符。
select substring(af.RESULTS from '{"searchtext":"(.+)","Source":null,"User":null}') as FINAL_RESULT from table af;