I have addresses like this
420 CONSUMER SQUARE (PET SMART PARKING LOT)
in a column and I want to remove the brackets and the word in that and the result should look like
420 CONSUMER SQUARE
How can I do this in PostgreSQL?
Please try this
SELECT regexp_replace('420 CONSUMER SQUARE (PET SMART PARKING LOT)', '\(.*\)', '');
You need to use regexp_replace
function
SELECT regexp_replace('420 CONSUMER SQUARE (PET SMART PARKING LOT)', '^(.*)\\(.*?\\)', '\\1')
-- or
SELECT regexp_replace('420 CONSUMER SQUARE (PET SMART PARKING LOT)', '\\(.*?\\)$', '')
Both examples will return 420 CONSUMER SQUARE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With