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

GREP exeptions between brackets

Engaged ,
Dec 14, 2020 Dec 14, 2020

Hi.

 

I have this GREP in a paragraphstyle :

 

 

 

 

(?<!\(.*)((firstExpression)|(secondExpression)|(thirdExpression))|(fourthExpression)

 

 

The text has to be changed is:

 

Text firstExpression Text Text Text secondExpression Text Text Text thirdExpression
fourthExpression Text Text (firstExpression, Text Text secondExpression Text Text Text, thirdExpression)

It doesn´t work at all.

 

But with this one:

 

 

(?<!\()((firstExpression)|(secondExpression)|(thirdExpression))|(fourthExpression)

 

Except words between brackets not standing directly behind a bracket(red). They don't get bold.

Where is the bug in my GREP?

 

 

TOPICS
Performance , Print , Type
874
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 ,
Dec 14, 2020 Dec 14, 2020

I did not understand your issue, can you specify what do you intend to find in your sample text, all the occurrences of firstExpression, secondExpression, thirdExpression, fourthExpression or only the one's that are inside ()

-Manan

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
Engaged ,
Dec 14, 2020 Dec 14, 2020

Okay.

In a catalogue there are, at each item, two paragraphs of the same style. In the first one the (key)words are in the text, without brackets. In the second paragraph the same words comes sometimes within brackets. The whole catalogue contains 8 words have to be catched with GREPs at each item-description.

 

This is how it has to look like:

 

Bildschirmfoto 2020-12-14 um 15.33.18.png

 

 

 

 

My problem is (in this case) word2 and word3 in the second paragraph.

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 ,
Dec 14, 2020 Dec 14, 2020

If I understand correctly then you just need to capture these unique words irrespective of whether they are between () or not. If that is the case then does the following not work for you

firstExpression|secondExpression|thirdExpression|fourthExpression

-Manan 

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
Engaged ,
Dec 14, 2020 Dec 14, 2020

Only if they are not between ( )!

 

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 ,
Dec 14, 2020 Dec 14, 2020

If possible, please show us these 8 words.

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
Engaged ,
Dec 14, 2020 Dec 14, 2020

They are German terms for printing on articles. But the point is, not to make them bold within parentheses.

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 ,
Dec 14, 2020 Dec 14, 2020

Ok

Dann hat dich bis jetzt jeder hier missverstanden.

 

Eine technisch nicht ganz so schöne, aber in den meisten Fällen funktionierende Variante wäre:

  • erstelle dir ein Zeichenformat Basis mit den Parametern des Absatzformates z.B. Farbe schwarz, regular
  • erstelle einen Grepstil, der alle gesuchten Begriffe (ohne die Umgebung einzubeziehen) in bold formatiert
  • erstelle dir einen Grepstil, der alles in runden Klammern mit dem Zeichenformat Basis überschreibt
\([^\)]*\)

 

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
Engaged ,
Dec 14, 2020 Dec 14, 2020

Ja, das wollte ich eigentlich vermeiden.

1.) würde aber gerne trotzdem eine Erklärung dafür haben, wieso mein reg. Ausdruck nicht funktioniert

2.) was bedeutet 

\([^\)]*\)
  • ?  
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 ,
Dec 14, 2020 Dec 14, 2020

Das Problem ist, dass Lookbehinds nicht mit unterschiedlichen Zeichenlängen umgehen können.

(Für positive Lookbehinds gibt seit einiger Zeit es die Alternative \K)

 

Aber du suchst nach Begriff/en, der/die NICHT nach einer öffnenden Klammer, eventuell mit unterschiedlicher Zeichenanzahl nachfolgend, stehen/t - und zusätzlich VOR eventuell unterschiedlichen Zeichen, die NICHT eine schließende Klammer sind, gefolgt von einer schließenden Klammer.

 

Mal sehen, ob die anderen Forenmitglieder nicht vielleicht doch noch einen Geniestreich „aus dem Hut“ zaubern können.

 

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 ,
Dec 14, 2020 Dec 14, 2020
\([^\)]*\)

bedeutet

  • öffnende Klammer
  • alles was keine schließende Klammer ist
  • null oder mehrere Male
  • schließende Klammer
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
Engaged ,
Dec 15, 2020 Dec 15, 2020

Danke für die Erklärung. Im Prinzip ging's mir um die eckige Klammer mit dem "Hütchen". Dieses kannte ich noch nicht. Werde es also erst einmal so versuchen, in der Hoffnung die Formatierung irgendwann mit einem einzigen Ausdruck lösen zu können.

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

Die Klammer mit dem „führenden Hütchen“ findet alles was NICHT in der Klammer steht.

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
Participant ,
Dec 15, 2020 Dec 15, 2020

Eigentlich würde für meine Zwecke auch:

\(.*\)

reichen, oder? Also alles was zwischen Klammern steht soll regular sein.

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

Ja.

Aber dieser Grep ist gierig und findet alles von der ersten öffnenden bis zur letzten schließenden Klammer.

 

Also zuviel.

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
Engaged ,
Dec 15, 2020 Dec 15, 2020
LATEST

 

\(.+?\)

kürzeste Entsprechung.

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