在 11g 中,您可以将 regexp_substr 与新参数一起使用(允许仅匹配子表达式):
SQL> with data as (
2 select 'i hav to [...] "string one".and the "Second one"' txt from dual
3 union all
4 select ' here is "table". "tiger" some other txt ' from dual)
5 SELECT regexp_substr(txt,'"([^"]*)"', 1, 2, '', 1) FROM data;
REGEXP_SUBSTR(TXT,'"([^"]*)"',1,2,'',1)
------------------------------------------------------------------------------
Second one
tiger
在 10g 中,您可以使用 replace 删除多余的 ":
SQL> with data as (
2 select 'i hav to [...] "string one".and the "Second one"' txt from dual
3 union all
4 select ' here is "table". "tiger" some other txt ' from dual)
5 SELECT replace(regexp_substr(txt,'"[^"]*"', 1, 2),
6 '"', '')
7 FROM data;
REPLACE(REGEXP_SUBSTR(TXT,'"[^"]*"',1,2),'"','')
------------------------------------------------
Second one
tiger