Skip to main content
Participant
June 30, 2023
Answered

GREP style every 5 line bold

  • June 30, 2023
  • 5 replies
  • 965 views

Hello!

 

I'm trying to make a GREP style to make every 5 line bold, I tried several ways but it is not working.
I have a paragraph style with a GREP, I tried two ways:

  1.  

 

 '(?<=\n.*\n.*\n.*\n.*\n).*$' 

 

2. 

 

(^.*\n){4}^.*

 

 

Both of them are not working, can somebody help me? 🙂

Full disclosure, I'm trying to achieve this:

Example

Text

For

This

Forum

Example

Text

For

This

Forum

Example

Text

For

This

Forum

Example

Text

For

This

Forum

This topic has been closed for replies.
Correct answer Peter Spier

Sorry, yes, the first line bold, then four with none. Forgot it was bold on the first line, not the fifth.

This is still cleaner using using rotating paragraph styles, though. Perhaps only two, one for the bold paragraph and one for the remainder if all one one paragraph. Forced line breaks are usually a bad way to break text.

5 replies

Willi Adelberger
Community Expert
Community Expert
June 30, 2023

If it is in one paragraph use line styles.

Peter Spier
Community Expert
Community Expert
June 30, 2023

If the lines are really separated by forced line breaks (soft returns) you don't really need GREP at all. Ordinary nested styles should work.

None through 4 Forced Line Break

Bold through 1 Forced Line Break

Repeat as required if the paragraphs have more than five lines.

Peter Spier
Community Expert
Peter SpierCommunity ExpertCorrect answer
Community Expert
June 30, 2023

Sorry, yes, the first line bold, then four with none. Forgot it was bold on the first line, not the fifth.

This is still cleaner using using rotating paragraph styles, though. Perhaps only two, one for the bold paragraph and one for the remainder if all one one paragraph. Forced line breaks are usually a bad way to break text.

Peter Spier
Community Expert
Community Expert
June 30, 2023

InDesign also has Line Styles which would work here, and would potetially allow for edits that change the lenght of the first line (or width of the column).  Same dialog as Nested Styles.

FRIdNGE
June 30, 2023

… Supposing a para with 5 lines separated by a soft-return:

 

(^.+\n)(?=(?1){3}.+$)

 

(^/)  The Jedi

FRIdNGE
June 30, 2023

… or:

 

(?<!\n)^.+

 

(^/)

FRIdNGE
June 30, 2023

… or use a nested line style applying the bold char style on the first line!

 

(^/)

Robert at ID-Tasker
Legend
June 30, 2023

If those lines are short - how about a table with alternate rows filling? 

 

Peter Spier
Community Expert
Community Expert
June 30, 2023

A better way to do this is to make each line a paragraph and sety up a set of rotatiung paragraph styles.

First paragraph style has second paragraph style set as Next Style, seconha has third as Next Style up to fifth paragraph style which uses first paragraph style as Next Style.