Replace string using regex pattern in PostgreSQL

regexp_replace(string_value, '(\w)s*=\s*(\d)', '\1', 'g')

The previous example extracts the name of a variable being assigned inside the text of string_value.