Struggling to understand how to make regexp_match string function in postgresql behave the way I want. I have a string and I want to replace any instance of multiple spaces with just one space. So for instance
'mitt romney'
becomes
'mitt romney'
I believe the following code should work:
SELECT regexp_replace('This is a test', '[ ]+', ' ');
The expected result would be
'This is a test'`
but instead I get back
'This is a test'`.
Its as if the replacement is only replacing the first match. Anyone know how to solve this?
Thanks