这是我表格REMARKS
列中的消息
{"StatusCode":"0","StatusDescription":"","message":"","transactionid":"404897688","enddate":"04/03/2017","formula":"ACCESS"}_SUBS
{"StatusCode":"0","StatusDescription":"","message":"","transactionid":"404894098","enddate":"04/03/2017","formula":"EVASION"}_SUBN
{"StatusCode":"0","StatusDescription":"","message":"","transactionid":"404889188","enddate":"05/03/2017","formula":"LES CHAINES CANAL+"}_SUBS
{"StatusCode":"0","StatusDescription":"","message":"","transactionid":"404880515","enddate":"06/03/2017","formula":"EVASION+"}_SUBS
我在查询中使用它
substr(remarks, (instr(remarks,'formula') + 10), 18) FORMULA
但我也得到了特殊字符}“_因为EVASION+
LES CHAINES CANAL+
EVASION
ACCESS
的长度不同。
有人可以解释如何排除这些特殊字符,并只获取FORMULA
列下显示的名称。
感谢
答案 0 :(得分:2)
以下是仅使用标准substr
和instr
函数(无正则表达式)的解决方案:
select substr( remarks, instr(remarks, '"formula":"') + 11,
instr(substr(remarks, instr(remarks, '"formula":"') + 11), '"') - 1 )
from inputs;
答案 1 :(得分:1)
如果备注列只是一个字符串,您可以尝试:
with x as (
select '{"StatusCode":"0","StatusDescription":"","message":"","transactionid":"404897688","enddate":"04/03/2017","formula":"ACCESS"}_SUBS' as remarks
from dual
)
select
regexp_substr(remarks, '"formula":"(.*?)"',1,1,'i',1)
from x;
输出:
ACCESS