• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Grep for finding and changing chapter titles.

Community Beginner ,
May 30, 2024 May 30, 2024

Copy link to clipboard

Copied

I'm trying to change the chapter titles to have numbers instead of text designating which chapter number it is in the book (ex. Chapter Fourth to Chapter 4). What would be the Grep query for this? Everything I've tried just generates cannot find match.Untitled-1.jpg

TOPICS
EPUB , Scripting , Type

Views

147

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , May 30, 2024 May 30, 2024

You can find a pattern - but you can't replace a pattern

That is the GREP would be 

Chapter\h[First|Second|Third|Fourth|Fifth|etc)

 

But you can't replace it with 

1 2 3 etc

 

Your best bet is to have a Paragraph Style and set the Automatic Numbering

And in the Automatic Numbering type in

Chapter^#

(I think it's that experiment with first)

 

Then search for

^Chapter\h.+?$

 

Then replace the whole line for the numbered paragraph which will always be

Chapter followed by the number

 

This describes

...

Votes

Translate

Translate
Community Expert , May 30, 2024 May 30, 2024

Here is an ever-so-slightly simpler variation on Eugene's answer (just one find/change) with a quick demo:

 

1. Edit your Chapter Number style to add the auto-numbers. If the entire document is in one file, use: 

Chapter ^#.

but if you are pulling multiple InDesign files into a book use

Chapter ^H.

2. Find/Change > GREP

   Find: .+ (to match everything on that line) and Paragraph style: Chapter Number (or whatever you named the style)

   Change: \s (because autonumbers need at least one characte

...

Votes

Translate

Translate
Community Expert ,
May 30, 2024 May 30, 2024

Copy link to clipboard

Copied

You can find a pattern - but you can't replace a pattern

That is the GREP would be 

Chapter\h[First|Second|Third|Fourth|Fifth|etc)

 

But you can't replace it with 

1 2 3 etc

 

Your best bet is to have a Paragraph Style and set the Automatic Numbering

And in the Automatic Numbering type in

Chapter^#

(I think it's that experiment with first)

 

Then search for

^Chapter\h.+?$

 

Then replace the whole line for the numbered paragraph which will always be

Chapter followed by the number

 

This describes my method

https://www.pubcom.com/blog/tutorials/indesign/toc-3/index.shtml

 

Then it's just find and replace to remove the text completely

And leave a blank character return - which inserts the autonumber - which will be Chapter 1/2/3/4 etc. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 31, 2024 May 31, 2024

Copy link to clipboard

Copied

LATEST

Thank you. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 30, 2024 May 30, 2024

Copy link to clipboard

Copied

Here is an ever-so-slightly simpler variation on Eugene's answer (just one find/change) with a quick demo:

 

1. Edit your Chapter Number style to add the auto-numbers. If the entire document is in one file, use: 

Chapter ^#.

but if you are pulling multiple InDesign files into a book use

Chapter ^H.

2. Find/Change > GREP

   Find: .+ (to match everything on that line) and Paragraph style: Chapter Number (or whatever you named the style)

   Change: \s (because autonumbers need at least one character on a line or they don't work)

   Change All

2024-05-30_17-56-59 (1).gif

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 30, 2024 May 30, 2024

Copy link to clipboard

Copied

Thanks, great you were able to put that together. I'm not always at the computer.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 30, 2024 May 30, 2024

Copy link to clipboard

Copied

I know! It's so hard when we are on our phones/ipads. I don't know how other people do it. 

 

~Barb

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 30, 2024 May 30, 2024

Copy link to clipboard

Copied

From my memory most of the time 😛

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 31, 2024 May 31, 2024

Copy link to clipboard

Copied

Thank you so much. I eventually did it by typing first, second, third .... into the find /change>text and putting the correct number in  the change to field, wich worked but was time coming. This method should be much more efficent and faster.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines