假设我有以下字符串:a=A#abc=Y#sps=Y#
在表的某个字段中。我想查询a
并得到A
这个查询:
select UPPER(REGEXP_SUBSTR(REGEXP_SUBSTR(
'a=Y#abc=Y#sps=Y#' ,
'a\=([^#]+)#?'), '[[:alpha:]]')) from dual;
我得到:
a
---------------
N
1 row selected
假设我有以下字符串:a=A#abc=Y#sps=Y#
在表的某个字段中。我想查询a
并得到A
这个查询:
select UPPER(REGEXP_SUBSTR(REGEXP_SUBSTR(
'a=Y#abc=Y#sps=Y#' ,
'a\=([^#]+)#?'), '[[:alpha:]]')) from dual;
我得到:
a
---------------
N
1 row selected
您可能需要一个 REGEXP_SUBSTR:
SQL> select regexp_substr(s,'(nonExcludableInd=)([^#]*)', 1, 1, '', 2)
2 from (
3 select 'nonExcludableInd=ABCD#includePrstInd=Y#cpeInd=Y#' as s from dual
4 );
REGE
----
ABCD
没有正则表达式的解决方案可能是:
select substr(s, startPosition, instr(s, '#', startPosition ) - startPosition)
from (
select instr(s,'nonExcludableInd=')+17 as startPosition, s
from (
select 'nonExcludableInd=A#includePrstInd=Y#cpeInd=Y#' as s from dual
)
)