oracle去除常见特殊字符方法

Posted 沧海·

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle去除常见特殊字符方法相关的知识,希望对你有一定的参考价值。

网上找了一大圈没找到想要的 于是自己手写了一份。有需要的朋友拿走,走前留个赞,谢谢。

create or replace function FUNC_STRING_CLEAN(data IN VARCHAR2) return varchar2
 IS
  data1   VARCHAR2 (2000);
begin
  data1:=data;
    if instr(data1,chr(39))>0 then 
       data1 :=  replace(data1,chr(39),'');
    end if; 
    if instr(data1,'"')>0 then 
     data1 :=  replace(data1,'"','');
    end if;
    if instr(data1,'`')>0 then 
     data1 :=  replace(data1,'`','');
    end if; 
    if instr(data1,'!')>0 then 
     data1 :=  replace(data1,'!','');
    end if;  
    if instr(data1,'(')>0 then 
     data1 :=  replace(data1,'(','');
    end if; 
     if instr(data1,')')>0 then 
     data1 :=  replace(data1,')','');
    end if; 
     if instr(data1,'*')>0 then 
     data1 :=  replace(data1,'*','');
    end if;
     if instr(data1,'^')>0 then 
     data1 :=  replace(data1,'^','');
    end if;   
      if instr(data1,'~')>0 then 
     data1 :=  replace(data1,'~','');
    end if;   
     if instr(data1,'……')>0 then 
     data1 :=  replace(data1,'……','');
    end if;   
     if instr(data1,'%')>0 then 
     data1 :=  replace(data1,'%','');
    end if; 
     if instr(data1,'——')>0 then 
     data1 :=  replace(data1,'——','');
    end if;  
     if instr(data1,'-')>0 then 
     data1 :=  replace(data1,'-','');
    end if;  
     if instr(data1,'+')>0 then 
     data1 :=  replace(data1,'+','');
    end if;   
     if instr(data1,'=')>0 then 
     data1 :=  replace(data1,'=','');
    end if;   
    if instr(data1,'[')>0 then 
     data1 :=  replace(data1,'[','');
    end if;    
     if instr(data1,'{')>0 then 
     data1 :=  replace(data1,'{','');
    end if;   
     if instr(data1,']')>0 then 
     data1 :=  replace(data1,']','');
    end if;   
    if instr(data1,'}')>0 then 
     data1 :=  replace(data1,'}','');
    end if;  
    if instr(data1,'|')>0 then 
     data1 :=  replace(data1,'|','');
    end if; 
     if instr(data1,'/')>0 then 
     data1 :=  replace(data1,'/','');
    end if; 
     if instr(data1,';')>0 then 
     data1 :=  replace(data1,';','');
    end if; 
     if instr(data1,':')>0 then 
     data1 :=  replace(data1,':','');
    end if; 
     if instr(data1,'”')>0 then 
     data1 :=  replace(data1,'”','');
    end if; 
     if instr(data1,'“')>0 then 
     data1 :=  replace(data1,'“','');
    end if; 
     if instr(data1,'"')>0 then 
     data1 :=  replace(data1,'"','');
    end if; 
     if instr(data1,';')>0 then 
     data1 :=  replace(data1,';','');
    end if; 
     if instr(data1,',')>0 then 
     data1 :=  replace(data1,',','');
    end if; 
     if instr(data1,',')>0 then 
     data1 :=  replace(data1,',','');
    end if; 
     if instr(data1,'<')>0 then 
     data1 :=  replace(data1,'<','');
    end if; 
     if instr(data1,'《')>0 then 
     data1 :=  replace(data1,'《','');
    end if; 
     if instr(data1,'>')>0 then 
     data1 :=  replace(data1,'>','');
    end if; 
     if instr(data1,'》')>0 then 
     data1 :=  replace(data1,'》','');
    end if; 
     if instr(data1,'。')>0 then 
     data1 :=  replace(data1,'。','');
    end if; 
     if instr(data1,'.')>0 then 
     data1 :=  replace(data1,'.','');
    end if; 
     if instr(data1,'?')>0 then 
     data1 :=  replace(data1,'?','');
    end if; 
     if instr(data1,'、')>0 then 
     data1 :=  replace(data1,'、','');
    end if; 
     if instr(data1,'@')>0 then 
     data1 :=  replace(data1,'@','');
    end if; 
     if instr(data1,'#')>0 then 
     data1 :=  replace(data1,'#','');
    end if; 
     if instr(data1,'¥')>0 then 
     data1 :=  replace(data1,'¥','');
    end if; 
     if instr(data1,'$')>0 then 
     data1 :=  replace(data1,'$','');
    end if; 
     if instr(data1,'!')>0 then 
     data1 :=  replace(data1,'!','');
    end if; 
     if instr(data1,'*')>0 then 
     data1 :=  replace(data1,'*','');
    end if;  
       if instr(data1,' ')>0 then 
     data1 :=  replace(data1,' ','');
    end if;  
          if instr(data1,'&')>0 then 
     data1 :=  replace(data1,'&','');
    end if;  
    return data1;
end FUNC_STRING_CLEAN;

以上是关于oracle去除常见特殊字符方法的主要内容,如果未能解决你的问题,请参考以下文章

oracle去除常见特殊字符方法

oracle去除常见特殊字符方法

Python中的去除字符串中的空格和特殊字符的方法都有哪些呢?

oracle 去掉字符,剩下数字

Python中常见字符串去除空格的方法总结

SQL去除数据库表中tab空格回车符等特殊字符的解决方法