我在下面的查询中紧跟着只显示大写字符串,但这里面临1个问题
SELECT SUBSTR(REGEXP_REPLACE(' ' || REGEXP_REPLACE(DESC, '(^[A-Z]|[a-z]|[A-Z][a-z]+|[,])', ''), ' +', ' '), 2, 9999),ID,DESC AS OUTPUT
FROM (
select ID,DESC
from MASTER where TABLE like 'D%'
)
上面的查询在以下示例中起作用:
“这是NUMBER”结果:NUMBER
但是在以下情况下失败
“ A_NUMBER是一个数字”结果:_NUMBER
答案 0 :(得分:0)
我想您应该按照以下常规程序将comma
替换为underscore
:
create table master( id int, "TABLE" varchar2(35),"DESC" varchar2(100));
insert into master values(1,'Dolphin1','A_NUMBER is a number');
insert into master values(2,'Dolphin2','This is a NUMBER');
SELECT SUBSTR(REGEXP_REPLACE(' '
|| REGEXP_REPLACE("DESC", '(^[A-Z]|[a-z]|[A-Z][a-z]+|[_])', ''), ' +', ' '), 2, 9999) AS OUTPUT
FROM (
select ID,"DESC"
from MASTER where "TABLE" like 'D%'
);
ID OUTPUT
1 NUMBER
2 NUMBER