add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
WITH regex_string AS (
SELECT '123456789' AS val FROM dual UNION ALL
SELECT '21-34-567' FROM dual UNION ALL
SELECT '2150-X1234-YZ' FROM dual UNION ALL
SELECT '21-22-93-001' FROM dual
)

SELECT SUBSTR(REGEXP_REPLACE(val, '[^0-9]+', ''), -4) AS last_four
FROM regex_string;








LAST_FOUR
6789
4567
1234
3001