Skip to main content
Participant
December 29, 2023
Question

HELP with GREP in indesign

  • December 29, 2023
  • 5 replies
  • 604 views

I would like to create a GREP for finding and changing

a whole sentence within quotation marks.

I have only found the GREP for a single word  ‭(")(‬\w‭+)(")‬ 

Anyone has the answer?

again, for a whole sentence

Thanks so much

Keren

 

This topic has been closed for replies.

5 replies

Peter Kahrel
Community Expert
Community Expert
January 2, 2024

The parentheses around the quotes aren't necessary, and instead of .+ you need .+? 

Without the question mark you match from the first quote in the text to the last one, skipping every quote inbetween -- i.e. Grep is greedy. The question mark avoids that.

Robert at ID-Tasker
Legend
January 2, 2024

We don't know OP's Change string... 

 

Maybe he wants to style inside - text between quotes - but also remove them? 

 

In this case parentheses will be needed:

 

() () () -> $2

 

But the greedy part is a very good point. 

 

Peter Kahrel
Community Expert
Community Expert
January 2, 2024

You would then use a lookbehind and a lookahead:

"\K.+?(?=")

This matches everthing between quotes but the format set in the Change format panel is applied only to whatever matches \.+?, not the quotes.

Robert at ID-Tasker
Legend
January 2, 2024

I'm not sure if it's just this forum or there is something "extra" in the GREP phrase you are using - and pasted here - but there are TWO extra hidden characters - "?":

 

This is my GREP expression - 3rd line:

 

Peter Kahrel
Community Expert
Community Expert
January 2, 2024

You didn't accidentally enter the Grep expression in the Text tab, did you? Please check.

Participant
January 2, 2024

yes, in the GREP.

we got it...

Thanks!

Peter Kahrel
Community Expert
Community Expert
December 29, 2023

Use 

 

".+?"

 

to include the quotes. If you want the sentence (whatever that means) without the quotes, use

 

"\K.+?(?=")

 

 

Participant
January 2, 2024

Thank you,

I tried these but they are not finding anything...

GREP GODS, I wonder what is the magic equation??

Robert at ID-Tasker
Legend
December 29, 2023

I'm not GREP guru and away from my computer right now - but maybe instead of (\w+) - (.+) will work?

"." means "any character".

 

But "sentence" is a bit tricky beast - as it can end with "?!.".

 

Also, you can have "." in the middle - like "i.e." or "e.g." or "J. Doe".

 

Or by "sentence" you just mean bunch of characters between quotation marks?

 

Participant
January 2, 2024

Hi,

Or by "sentence" you just mean bunch of characters between quotation marks?  YES

(I tried (.+) - it does not work)

Thanks

Robert at ID-Tasker
Legend
January 2, 2024

Works for me:

 

 

Can you upload sample INDD file?