Skip to main content
Participant
June 12, 2025
Answered

GREP Style text inside quotes

  • June 12, 2025
  • 1 reply
  • 309 views

Hi all—I'm experienced with Indesign, but not so much with GREP. Hoping to get helpw with what is most likely a syntax error. 

I am trying to set up a GREP expression that will style text inside of quotes within a paragraph (including the quote marks. I set up this GREP expression: ~{.+~}\s

This works to apply the style to the quote text; however, when there is more than one string of quoted text within a paragraph, all text between the first opening quote mark and the final closing quote mark in the paragraph gets styled, as seen here:

 

In this case, the words > I would go to rehearsal every day and say, < should not have the sans serif character style applied. I'm assuming there is code that should be included to "reset" the GREP call when the first closed quote mark character is reached, then reapply when the following open quote character is encountered, etc?

Thank you in advance.

Correct answer danaken3

Add a question mark after the plus sign to indicate that you are searching for the shortest match (by default it will look for the longest match):

~{.+?~}

I'd also remove the white space character \s because if the quote comes at the end of a story and there is no white space after it, the original search will miss it.

1 reply

danaken3
danaken3Correct answer
Participating Frequently
June 12, 2025

Add a question mark after the plus sign to indicate that you are searching for the shortest match (by default it will look for the longest match):

~{.+?~}

I'd also remove the white space character \s because if the quote comes at the end of a story and there is no white space after it, the original search will miss it.

JOutisAuthor
Participant
June 12, 2025

That solved it. Thanks!