模式匹配的基本子串搜索

时间:2016-06-08 17:57:29

标签: postgresql

如何根据模式从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;

1 个答案:

答案 0 :(得分:0)

想出来。我错过了'+'字符。

        select substring(af.RESULTS from '{"searchtext":"(.+)","Source":null,"User":null}') as FINAL_RESULT from table af;