Skip to main content
Bedazzled532
Inspiring
May 10, 2025
Answered

Highlight text present in the last parenthesis

  • May 10, 2025
  • 1 reply
  • 336 views

I want to apply character style named RED using GREP Styles/Nested Styles but only till the first : from the start and the last parenthesis. What grep should I use ?

 

Here is the sample text:

Trans of line: This is the (translation) of the line taken from the book (Tintin) comic book. Also take care of colon: coming in the text. (Tintin-Cigars of Pharoah)

 

Second Scenario:

Translation: This is the (translation) of the line taken from the book (Tintin) comic book. Also take care of colon: coming in the text. (Tintin)

Correct answer Eugene Tyson

You can do it with a Nested Style (file attached) but it's heavily rule based - so the structure needs to remain the same in terms of brackets and colons - as I based the style on through 1 : which makes it work

 

You could do with Combo Nested Style and GREP Style

Your nested style looks like this

 

And the GREP Style looks like this

 

\(([^()]+)\)\s*$

Attached file combo nested grep style

 

Or do it all as a single Grep Style 

This is a greedy grep and not working

\(([^()]+)\)\s*$|^.+?\:

 

Or as separate GREP styles

First part of sentence

^.+?\:

Last part of sentence in brackets

\(([^()]+)\)\s*$

 

Best to do as Nested Style and Grep combo in my opinion 

 

You can use 2 greps in the one style

Achieves the same thing 

 

1 reply

Eugene TysonCommunity ExpertCorrect answer
Community Expert
May 10, 2025

You can do it with a Nested Style (file attached) but it's heavily rule based - so the structure needs to remain the same in terms of brackets and colons - as I based the style on through 1 : which makes it work

 

You could do with Combo Nested Style and GREP Style

Your nested style looks like this

 

And the GREP Style looks like this

 

\(([^()]+)\)\s*$

Attached file combo nested grep style

 

Or do it all as a single Grep Style 

This is a greedy grep and not working

\(([^()]+)\)\s*$|^.+?\:

 

Or as separate GREP styles

First part of sentence

^.+?\:

Last part of sentence in brackets

\(([^()]+)\)\s*$

 

Best to do as Nested Style and Grep combo in my opinion 

 

You can use 2 greps in the one style

Achieves the same thing 

 

Bedazzled532
Inspiring
May 11, 2025

@Eugene Tyson Thanks for the codes. It worked.

Community Expert
May 11, 2025

 

 

If you run into any quirks let us know 😎