Skip to main content
Inspiring
December 7, 2022
Answered

InDesign GREP

  • December 7, 2022
  • 3 replies
  • 3112 views

I'm sure there's a way to do this with GREP but I cannot  find it.

I need to  find all instances of Chapter [One, Two, Three, etc - all the way to 65] followed by a paragraph and change that to delete the paragraph

so Chapter One ^p^p change to Chapter One^p

Chapter Two ^p^p change to Chapter Two^p

and so on  until Chapter Sixty-five^p^p

Any help is  truly appreciated

This topic has been closed for replies.
Correct answer brian_p_dts

Find: (Chapter .+)\r

Replace: $1

3 replies

Peter Spier
Community Expert
Community Expert
December 8, 2022

So it looks to me like you really have a more general problem than just chapter titles.

If I understand correctly you want to remove extra paragraph returns at the end of your chapter titles, but you should want to remove them everywhere. There should already be a saved query installed in the Find/Change panel called Multiple Return to Single Return: find ~b~b+ and change to \r,  (apparently the ~b and \r are equivalent) but I think I would prefer a slight modification: Find (\r)\r+ and change to $1  The reason to do it this way is to preserve styling assigned in the first return (hopefully Uwe Laubender will step in to correct me if that's correct).

In any case, it should be clear that you don't need to know what comes before the multiple returns to fix them, and if you want to limit the search to a single paragraph style for your chapter heads you can do that.

The main problem I see with the suggested expressions I see above is they don't check for additional returns after the first one and presume there will always be two. This would be dangerous if there were cases where there was in fact only one return, and an incomplete fix for three or more.

Inspiring
December 8, 2022

thanks Peter but no - it was a very specific instance - now that I have the extra return removed I can use the "apply next style" and  in one fell swoop format my chapter headings, first paragraphs and  following text. I do know about the  find multiple returns and multiple spaces queries

Community Expert
December 8, 2022

If you have a them as a paragraph style

 

Find

(^.+?)\r

Change to

$1

 

Find Format

<click into the blank box> 

Select the Style from the Drop menu

 

It will find only that style that is applied

 

No danger of finding Chapters in other styles.

 

Or swap the Find grep for @brian_p_dts as it's more specific.

 

 

Inspiring
December 8, 2022

thank you but if  they had been styled correctly, I would have been able to address them as you siggested. Unfortunately they were not.

brian_p_dts
Community Expert
brian_p_dtsCommunity ExpertCorrect answer
Community Expert
December 8, 2022

Find: (Chapter .+)\r

Replace: $1

m1b
Community Expert
Community Expert
December 8, 2022

A refinement on brian's answer, just in case you also have "Chapter" in other paragraphs that you don't want to change.

 

Find:

 

(?i)(chapter ((ten|eleven|twelve|(thir|four|fif|six|seven|eigh|nine)teen)|((twenty|thirty|fourty|fifty|sixty|seventy|eighty|ninety)[ -]?)?(one|two|three|four|five|six|seven|eight|nine)?))\r\r

 

 

Change:

 

$1\r

 

 

(Note: I haven't exhaustively tested this!)

- Mark

Inspiring
December 8, 2022

thank you, Brian's answer worked fine. I knew how many chapters and was able to confirm  that only those were replaced by the number of  changes made that the query reported