I want to use the Oracle REGEXP_REPLACE to remove some dots from a String. I have to remove from the second dot if exists. For example:
4 => 4
5 => 5
5.1 => 5.1
5.1.1 => 5.11
5.1.2 => 5.12
5.1.2.1 => 5.121
5.1.2.2 => 5.122
6 => 6
I have this
select REGEXP_REPLACE(num, '(\d+)(\.)(\d+)(\.)(\d+)', '\1.\3\5')
from my_table;
the problem is that my query is made just for two dots. If the string has more than two dots, I have to modify the query to accept more dots and so. Is there any way to do this automatically?
Thanks