• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Keep Matter between parentheses, delete rest using GREP

Enthusiast ,
Apr 26, 2023 Apr 26, 2023

Copy link to clipboard

Copied

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.

TOPICS
How to

Views

409

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 26, 2023 Apr 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.

Screen Shot 2023-04-26 at 11.28.59 AM.png

 Do the same for the Blue

Votes

Translate

Translate
Community Expert ,
Apr 26, 2023 Apr 26, 2023

Copy link to clipboard

Copied

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.

Screen Shot 2023-04-26 at 11.28.59 AM.png

 Do the same for the Blue

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 26, 2023 Apr 26, 2023

Copy link to clipboard

Copied

Yes I have done that already. But I wanted to do it using grep.
Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 27, 2023 Apr 27, 2023

Copy link to clipboard

Copied

Brad @ Roaring Mouse One more thing which I forgot to tell. I am sorry for that.

The text which I have is all in black. I just wanted to show what I need and what I dont, thats the reason I did color coding. Any other suggestions would be appreciated.

 

Thanks once again

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 27, 2023 Apr 27, 2023

Copy link to clipboard

Copied

LATEST

Ah!  Sorry!  That does make a difference indeed! 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines