WITH t AS ( SELECT '' v FROM dual UNION ALL SELECT '000000000000' FROM dual ) SELECT v , SUBSTR(REGEXP_REPLACE(v, '(.{4})', '-\1'), 2) x , LTRIM(REGEXP_REPLACE(v, '(....)', '-\1'), '-') x , REGEXP_REPLACE(v, '(....)(....)(....)', '\1-\2-\3') x , REGEXP_REPLACE(v, '(....)(....)', '\1-\2-') x , REGEXP_REPLACE(v, '(....)', '-\1-', 5, 1) x , REGEXP_REPLACE(v, '(....)', '-\1-', 1, 2) x , REPLACE(TO_CHAR(v, 'fm0000,0000,0000'), ',', '-') x FROM t ;