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

How to use GREP to select specific in bracket words?

New Here ,
Feb 11, 2025 Feb 11, 2025

I am currently using this GREP to select when there are certain words+Numbers or other characters in brackets.

(\(|\[)(Bild|Fig|Pos|Item|Pic|Photo|Abb)\s*\.*\d*\+*\d*\.*\s*~e*(\)|\])

 

This expression isn't ideal because it won't work if there are numbers and plus symbols one after another multiple times (as seen in the screenshot below).

Untitled-1.png

Is there a GREP expression that finds open bracket + Word and then selects everything until it finds a closed bracket?

TOPICS
How to
523
Translate
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 , Feb 11, 2025 Feb 11, 2025

The simplest would be to look for ([word] up to the next closing parenthesis:

 

 

[(\[]((Bild|Fig|Pos|AbbItem|Pic|Photo)\.?).+?[)\]]

 

But if you want to match numbers and maybe +, then use this:

 

[(\]]((Bild|Fig|Pos|AbbItem|Pic|Photo)\.?)[\d\+]+[)\]]

 

 

Translate
LEGEND ,
Feb 11, 2025 Feb 11, 2025

I'm not a GREP expert - but until someone better than me will chime in - you could take your "numbers" part in brackets and add "+" afterwards - it will tell InDesign to look for multiple occurrences: 

 

(\s*\.*\d*\+*\d*\.*\s*~e*)+

 

Or it should be possible to shorten it to ".+" but as GREP in InDesign is "greedy" - "?" need to be added in the right place - but I'm not good at it and I'm replying from my phone.

 

Translate
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 ,
Feb 11, 2025 Feb 11, 2025

The simplest would be to look for ([word] up to the next closing parenthesis:

 

 

[(\[]((Bild|Fig|Pos|AbbItem|Pic|Photo)\.?).+?[)\]]

 

But if you want to match numbers and maybe +, then use this:

 

[(\]]((Bild|Fig|Pos|AbbItem|Pic|Photo)\.?)[\d\+]+[)\]]

 

 

Translate
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
LEGEND ,
Feb 11, 2025 Feb 11, 2025

@Peter Kahrel

 

I think OP wants also to include occurrences in square brackets - could you please modify your examples?

 

Translate
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 ,
Feb 11, 2025 Feb 11, 2025

Hadn't spotted those, thank you.

Translate
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
New Here ,
Feb 12, 2025 Feb 12, 2025
LATEST

Thank you!
This solved my problems.

Translate
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