I'm trying to change a value in oracle with regex:
input: <input id="f_alta">13/10/2016 10:10:10</input>
output: 13/10/2016 10:10:10
well, to get inside the node I use: ([\s0-9/:]+) but is no working, anyway I use: ([ 0-9/:]+) and works, why is not working with the first one?
I'm using oracle sql developer for tests.
Example:
NOT WORKING:
select REGEXP_REPLACE('<input id="f_alta">13/10/2016 10:10:10</input>', '<input id="f_alta">([\s0-9/:]+)</input>', '\1' ) from dual
WORKING:
select REGEXP_REPLACE('<input id="f_alta">13/10/2016 10:10:10</input>', '<input id="f_alta">([ 0-9/:]+)</input>', '\1' ) from dual
Since the \s
is a Perl-like construct and Oracle regex is POSIX based, it is safer to use the POSIX character class [:space:]
(to include vertical whitespace) or [:blank:]
(to only match spaces and tabs).
E.g. use
([[:space:]0-9/:]+)
Remember to always use POSIX character classes inside bracket expressions (so, to match one alpha character, use [[:alpha:]]
, i.e. the name of the class must be inside colons and double square brackets).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With