I need to extract only 5 digit numbers from a string using REGEXP sql in postgresql or redshift DB
For example,
f 34 123 54321 123456
above string should return
54321
I am able to get only numbers from string but not only 5 digit number
select REGEXP_REPLACE('f 34 123 54321 123456', '[^0-9]') five_digit_number
--returns 3412354321123456