Extracting Numbers from Mixed Text Using REGEXP_REPLACE
Published September 21, 2025
By Sai Sree Ram Gundepudi
Debug logs often embed numbers within text. To extract only the numbers:
SELECT TO_NUMBER(REGEXP_REPLACE('INV#8674767JSDEPOSIT PO12345678', '\\D', '')) AS out_put
FROM dual;
SELECT TO_NUMBER(REGEXP_REPLACE('INV#8674767JSDEPOSIT PO12345678', '[^0-9]+', '')) AS out_put
FROM dual;Both return 867476712345678, effectively isolating digits from alphanumeric strings.