Keep Matter between parentheses, delete rest using GREP
- April 26, 2023
- 1 reply
- 733 views
Hi
I have received a text from a customer (screenshot attached).
I want to keep all the matter between the parentheses intact and delete rest of them.
Also, I want to delete the matter including parentheses marked in blue.
I have written following query:
Find: \(\x{0635}:\h?\d+\)
Change to: nothing
This deletes the parentheses with the matter which is marked in blue.
Then I wrote a second query which selects the text between parentheses (marked in red). How do I keep this intact and delete the rest of the matter?
I tried (*Skip)(*fail) method but I guess I am not very good at it.
This is the query I wrote to select the text marked in red which I want to keep.
Find: (?<=\()[^()]+(?=\))
I then tried another query to delete the matter in black in one go.
F: (\(.+?\))(?:.+)
C: $1
This query does not work as it should. Its leaving much of the black matter unchanged.
Any help would be appreciated.
Thanks.

