我有一个列名为Table的表,如下所示:
Name
ftyrt_hghjh
hgdhfg_jhjh
dfgfh#hvhvj
vhhghf=dvdf
hdghfg%bdjfb
我想分隔特殊字符并显示如下:
Name Special_Char
ftyrt_hghjh _
hgdhfg_jhjh _
dfgfh#hvhvj #
vhhghf=dvdf =
hdghfg%bdjfb %
答案 0 :(得分:1)
with temp as
(select 'ftyrt_hghjh' as name from dual
union all
select 'hgdhfg_jhjh' as name from dual
union all
select 'dfgfh#hvhvj' as name from dual
union all
select 'vhhghf=dvdf' as name from dual
union all
select 'hdghfg%bdjfb' as name from dual
)
select name AS "Name"
,regexp_substr(name, '[^a-zA-Z]') AS "Special Character"
from temp
使用regexp匹配a-z
或A-Z
以外的任何字符
Match Special Character
答案 1 :(得分:0)
您可以使用函数translate来替换所有非特殊字符,实际上是从输入字符串中删除它们。
假设特殊字符是
_#=%
并假设非特殊字符从a到z都是小写的 以下内容将起作用:
translate (table.name, '_#=%abcdefghijklmnopqrstuvwxyz', '_#=%')