【问题标题】:how to remove a class of character from the string in oracle sql如何从oracle sql中的字符串中删除一类字符
【发布时间】:2015-11-23 20:06:17
【问题描述】:

我想从 oracle sql 中的字符串中删除以下非法字符列表。如果给定的字符串出现任何一次或多次。

我需要用空格替换它们。

•   Double quotes( “ )
•   Semi-colon ( ; )
•   Plus sign ( + )
•   Square brackets ( [ ] )
•   Backslash ( \ )
•   Vertical Bar ( | )
•   Greater Than (>)
•   Less Than (<)

我该如何使用REGEXP_REPLACE

我正在考虑使用类似的东西

  select REGEXP_REPLACE('<stack>>||\[]flow[]+"";' , [[:";\+\[\]\\|><:]],''')
   from dual;

但是,不确定如何制作用户定义的字符类。

【问题讨论】:

    标签: oracle11g


    【解决方案1】:

    在标准 Oracle 函数可以使用的情况下,为什么还要使用 regexp 函数?

    translate (mystring, 'x";+[]\|><', 'x')
    

    存在“x”是因为 translate 不能很好地处理空替换字符串!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-27
      • 2019-02-06
      • 2014-10-19
      • 1970-01-01
      • 2020-02-02
      • 1970-01-01
      • 2014-07-30
      • 1970-01-01
      相关资源
      最近更新 更多