Skip to main content
Participant
January 26, 2023
Question

GREP Change All

  • January 26, 2023
  • 4 replies
  • 1014 views

I am trying to change paragraph styles in a large document with a GREP search. The code works when I use the CHANGE function, but when I click CHANGE ALL it applies all of my changes except the paragraph style. Does anyone know what might be upsetting the GREP search?

This topic has been closed for replies.

4 replies

Peter Kahrel
Community Expert
Community Expert
January 28, 2023

It's a strange case. I think the problem is that InDesign gets confused because you change the number of paragraphs while Change All' is executed (you halve the number of paragraphs). There is a workaround, however: do it with two queries.

 

The first query is like the one you have now. You could remove the paragraph style from the Change Format panel to make the query more efficient, but in principle it doesn't matter much. Similarly, you could remove the $ from the Find What entry because it doesn't do anything.

 

After executing this first query you have speaker and utterance in one paragraph and the character style is applied to the speakers. Now run a second query that applies the paragraph style to all instances of the character style: leave the Find What and Change To fields empty, set the Find Format panel to the character style (nothing else), and set the Change Format panel to the paragraph style.

 

That's two queries, but you can use a query runner script to run them together. The simplest one (I think) is this one:

https://creativepro.com/files/kahrel/indesign/grep_query_runner.html

 

P.

Peter Kahrel
Community Expert
Community Expert
January 27, 2023

I too am intrigued: Find paragraphs that consist of two or more upper-case letters and which are followed by a return character. Apply a paragraph style and a character style to that paragraph and replace the return character with a period. (This would ignore the last paragraph if it's not followed by a return character.)

 

Why not use a single paragraph style for this? That doesn't anser why your query doesn't work, but may enable you to get what you want.

pixxxelschubser
Community Expert
Community Expert
January 27, 2023

Hi Peter,

I was already afraid that I was the only one who thought that way.
😉

brian_p_dts
Community Expert
Community Expert
January 26, 2023

What is the GREP search? Can you screenshot your FC window?

Participant
January 26, 2023

The GREP search is attached. To clarify, this is a GREP search that I know works because I use it often in documents in general. Also, it works in this document in particular--it changes the paragraph style when I do a FIND/CHANGE but for some reason not for CHANGE ALL. 

pixxxelschubser
Community Expert
Community Expert
January 26, 2023

Hi @Cal26021403g9p3 

It also works for me with exactly the same result as for you.

 

But I have a few questions:

Sorry. But neither the GREP nor the replacement with the styles make sense to me. Can you please show screenshots of the text before and after the replacement? Maybe pictures are a bit more self-explanatory.

  • Why replace with a character style AND a paragraph style?
  • Why remove the paragraph sign and replace with a period and no space?

 

  • Does this simplified GREP

 

^(\u+)\r

 

 do the same for you with FIND/CHANGE?

HARSHIKA_VERMA
Community Manager
Community Manager
January 26, 2023

Hi @Cal26021403g9p3,

 

Thank you for reaching out. Would you mind checking this article: https://helpx.adobe.com/indesign/using/find-change.html#search_using_grep_expressions, and also check the examples of GREP searches that might help you?

 

I am also keeping the discussion open for our experts, who might have more suggestions for you.

 

Thanks,

Harshika