Oracle PL/SQL中的正则表达式从包含电话号码的字符串中删除不需要的字符

use*_*938 3 regex string oracle plsql replace

我需要从Oracle中的字符串中删除字符 - ,+,(,)和空格.字符串中的其他字符都是数字.可以执行此操作的功能是REGEXP_REPLACE.我需要帮助编写正确的正则表达式.

示例:字符串'23 +(67 -90'应返回'236790'字符串'123456'应返回'123456'

Jus*_*ave 6

就像是

SQL> ed
Wrote file afiedt.buf

  1  with data as (
  2    select 'abc123def456' str from dual union all
  3    select  '23+(67 -90' from dual union all
  4    select '123456' from dual
  5  )
  6  select str,
  7         regexp_replace( str, '[^[:digit:]]', null ) just_numbers
  8*   from data
SQL> /

STR          JUST_NUMBERS
------------ --------------------
abc123def456 123456
23+(67 -90   236790
123456       123456
Run Code Online (Sandbox Code Playgroud)

应该这样做.这将从字符串中删除任何非数字字符.