with a as (
select '98 46134679////1' as before from dual
union all
select '98/46134679/1' as before from dual
union all
select '98 / 46134679 / 1' as before from dual
union all
select '98 ////// 46134679 1' as before from dual
)
select a.before, regexp_replace(a.before, '^([0-9][0-9])([ /-])+([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9])([ /-]+)([0-9])$', '\1-\3-\5') as formatted from a
BEFORE | FORMATTED | 98 46134679////1 | 98-46134679-1 | 98/46134679/1 | 98-46134679-1 | 98 / 46134679 / 1 | 98-46134679-1 | 98 ////// 46134679 1 | 98-46134679-1 |
---|