Sum*_*man 1 oracle substring oracle10g
我需要你对给定问题的帮助
我有一个带有列工人的表,它提供了数据
thorax1 [00400-00479] head1 [00100-00228] lab66 [lab661]
the whole date is in single column
我们有一个页面,我们可以命令删除任何给定的字符串.
为了删除记录,我们只给出方括号中的代码.
例如,如果我们需要删除 head1 [00100 - 00228],我们只给00100 - 00228删除字符串.
这里我的问题是写一个查询,我们可以给00100 - 00228或00400 - 00479删除head1 [00100 - 00228]或thorax1 [00400 - 00479] 记录.
SQL> with t(col) as (
2 select 'thorax1 [00400 - 00479] head1 [00100 - 00228] lab66 [lab661]' from dual
3 )
4 select regexp_replace(col,'\s{0,1}[[:alnum:]]* \[00100 - 00228\]','') from t
5 ;
REGEXP_REPLACE(COL,'\S{0,1}[[:ALNUM:]]
--------------------------------------
thorax1 [00400 - 00479] lab66 [lab661]
SQL> with t(col) as (
2 select 'thorax1 [00400 - 00479] head1 [00100 - 00228] lab66 [lab661]' from dual
3 )
4 select regexp_replace(col,'\s{0,1}[[:alnum:]]* \[00400 - 00479\]','') from t
5 /
REGEXP_REPLACE(COL,'\S{0,1}[[:ALNUM:]
-------------------------------------
head1 [00100 - 00228] lab66 [lab661]
SQL> with t(col) as (
2 select 'thorax1 [00400 - 00479] head1 [00100 - 00228] lab66 [lab661]' from dual
3 )
4 select regexp_replace(col,'\s{0,1}[[:alnum:]]* \[lab661\]','') from t
5 /
REGEXP_REPLACE(COL,'\S{0,1}[[:ALNUM:]]*\[LAB6
---------------------------------------------
thorax1 [00400 - 00479] head1 [00100 - 00228]
Run Code Online (Sandbox Code Playgroud)
在10G中尝试这一个(将"COL"列名称从因子列表移动到SELECT语句):
with t as (
select 'thorax1 [00400 - 00479] head1 [00100 - 00228] lab66 [lab661]' col from dual
)
select regexp_replace(col,'\s{0,1}[[:alnum:]]* \[lab661\]','') from t
/
Run Code Online (Sandbox Code Playgroud)