How do I extract all digits from a string with regex in pgsql?
select regexp_matches('dsa8a552a5a2a5?', '\d+');
Will output only 8.
Need to get
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
regexp_replace, globally replacing non-digits by an empty string:
select regexp_replace('dsa8a552a5a2a5?', '\D', '', 'g'); regexp_replace ---------------- 8552525