ZiT*_*TAL 3 regex oracle whitespace
我正在尝试使用正则表达式更改oracle中的值:
input: <input id="f_alta">13/10/2016 10:10:10</input>
output: 13/10/2016 10:10:10
Run Code Online (Sandbox Code Playgroud)
好吧,要进入节点,我要使用:([\ s0-9 /:] +)但不能正常工作,反正我要使用:([0-9 /:] +)正常工作,为什么不使用第一个一?
我正在使用oracle sql开发人员进行测试。
例:
不工作:
select REGEXP_REPLACE('<input id="f_alta">13/10/2016 10:10:10</input>', '<input id="f_alta">([\s0-9/:]+)</input>', '\1' ) from dual
Run Code Online (Sandbox Code Playgroud)
工作:
select REGEXP_REPLACE('<input id="f_alta">13/10/2016 10:10:10</input>', '<input id="f_alta">([ 0-9/:]+)</input>', '\1' ) from dual
Run Code Online (Sandbox Code Playgroud)
由于\ss是类似于Perl的构造,而Oracle regex是基于POSIX的,因此使用POSIX字符类[:space:](包括垂直空格)或[:blank:](仅匹配空格和制表符)更安全。
例如使用
([[:space:]0-9/:]+)
Run Code Online (Sandbox Code Playgroud)
切记始终在方括号表达式内使用POSIX字符类(因此,要匹配一个字母字符,请使用[[:alpha:]],即类名必须在冒号和双方括号内)。