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

InDesign GREP eror

Community Beginner ,
Jun 15, 2020 Jun 15, 2020

Copy link to clipboard

Copied

When searching items between Parenthesis () with the GREP method \(.+\) why do I get selected the text starting from the first "(" untill the last ")" in that paragraph, if there is more than one () in that paragraph?

it should have select only one "(" to the next ")"

or maybe i'm using GREP wrong?

see photo

Annotation 2020-06-15 192726.png

TOPICS
How to , Type

Views

429

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 , Jun 15, 2020 Jun 15, 2020

You coukd try the following

\(.+?\)

Which means select as small no. of characters as possible in between () so this should fix you issue

 

-Manan

Votes

Translate

Translate
Community Expert ,
Jun 15, 2020 Jun 15, 2020

Copy link to clipboard

Copied

You coukd try the following

\(.+?\)

Which means select as small no. of characters as possible in between () so this should fix you issue

 

-Manan

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 ,
Jun 16, 2020 Jun 16, 2020

Copy link to clipboard

Copied

^^ because by default GREP is greedy: it tries to match as much as possible with each of the '+', '*', and '{..}' repeat modifiers.

 

You can see this (more obvious) if you search for something simple like

a+

 

If GREP was not greedy, it would only select the very first occurrence of an 'a' -- usually not what you would want here! (Because then why have a '+' there.) Adding a '?' immediately after the repeat modifier changes the behavior to match as soon as possible. For example, where 'a+' would match all the 'a's in "aaargh!", 'a+?' only matches the first one.

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 Beginner ,
Jun 18, 2020 Jun 18, 2020

Copy link to clipboard

Copied

LATEST

thank you manan, your answer is correct.

this GREP code \(.+\) is selectin all items in aparragraph that is in between ()

hershy_schnitzler_0-1592535963828.png

and this GREP code \(.+?\) is selecting only one () at a time

 

Annotation 2020-06-18 230800.png

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 ,
Jun 15, 2020 Jun 15, 2020

Copy link to clipboard

Copied

Another option could be

\([^()]+\)

 

Which basically means select all characters between () which are any characters but not ()

 

-Manan

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