For example,string is abc123CD need to find out a method to read only numbers in the string i.e.
abc123CD
select a_postgres_function(\'a
If you want to get all digit characters from the string (not just the first group), it is easier to remove all characters, which aren't a digit:
select regexp_replace('abc123CD45ef', '[^\d]+', '', 'g'); -- regexp_replace -- -------------- -- '12345'