Skip to main content
Bedazzled532
Inspiring
April 26, 2023
Answered

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.

This topic has been closed for replies.
Correct answer Brad @ Roaring Mouse

I think you're going deeper into this then you need to. Simply do a Find and Replace for any text that's Black and Replace it with nothing (i.e leave "Find what" and "Change to" blank.

 Do the same for the Blue

1 reply

Brad @ Roaring Mouse
Brad @ Roaring MouseCorrect answer
Inspiring
April 26, 2023

I think you're going deeper into this then you need to. Simply do a Find and Replace for any text that's Black and Replace it with nothing (i.e leave "Find what" and "Change to" blank.

 Do the same for the Blue

Bedazzled532
Inspiring
April 26, 2023
Yes I have done that already. But I wanted to do it using grep.
Thanks