If you want to only extract digits from a string in Postgres, we can do it using regexp_replace. \D tell not digit and ‘g’ stand for global.
SELECT NULLIF(regexp_replace('OTHERdsfd4 323 2323d42324 3ssf3 432`sfd', '\D','','g'), '')::numeric AS result -- Output: 432323234232433432
Happy Coding!!
Leave a Reply