QGIS – Removing Data Existing in Closed Brackets Using Regular Expression

qgisregular expression

I have a dataset that contains a number of closed brackets with data. I don't want the data which exists in the brackets. How can I remove that in QGIS?

Mcdonalds(Park Avenue)
KFC (Park Avenue) Restaurant
(Financial District) Hotel Marriot

Best Answer

Use this expression, where name is the name of the input attribute field:

regexp_replace ("name", '\\(.+\\)','')

If you also want to avoid any whitspaces (space etc.) at the beginning or end of the text field, e.g. resulting from deleting a bracket at the beginning (like your 3rd example), add a trim() function:

trim (regexp_replace ("name", '\\(.+\\)',''))

enter image description here