将 REGEXP_SUBSTR 与 11g 一起使用
WITH test AS (SELECT 'ABCD_EFGH_THIS_IJKL' AS thetext FROM DUAL
UNION SELECT 'ABAB CDCD EG BCD' FROM DUAL)
SELECT REGEXP_SUBSTR( TEST.THETEXT, 'ABCD_EFGH_([^_]*).*', 1, 1, 'i', 1)
FROM test
编辑
这可以在不使用正则表达式的情况下完成。
WITH test AS (SELECT 'ABCD_EFGH_THIS_IJKL' AS thetext FROM DUAL
UNION SELECT 'ABAB CDCD EG BCD' FROM DUAL)
select TEST.thetext
, instr(TEST.thetext, 'ABCD_EFGH_') + length('ABCD_EFGH_') START_POS
, instr(TEST.thetext, '_', length('ABCD_EFGH_') + 1) END_POS
, substr
(TEST.thetext
,instr(TEST.thetext, 'ABCD_EFGH_') + length('ABCD_EFGH_') --START_POS
,instr(TEST.thetext, '_', length('ABCD_EFGH_') + 1) - (instr(TEST.thetext, 'ABCD_EFGH_') + length('ABCD_EFGH_')) --END_POS - START_POS
) RESULT
FROM test