Reply To: Use GREP to apply Paragraph Style X when text is between Paragraph Style Y and Z

Home Page / Forums / General InDesign Topics (CLOSED) / Use GREP to apply Paragraph Style X when text is between Paragraph Style Y and Z / Reply To: Use GREP to apply Paragraph Style X when text is between Paragraph Style Y and Z

#83416
Peter Kahrel
Participant

A GREP expression can match things in one style only: you can’t specify different styles for a search. But if your ingredients lists are always preceded by the word ‘Ingredients’ and followed by the word ‘Directions’, then you can use this GREP to apply your ingredients style:

Find what: (?s)(?<=Ingredients\r).+?(?=\rDirections)
Change to: <Leave empty>
Change format: <ingredients style>

(?s) // Consider the text as a single line so that . matches \r
(?<=Ingredients\r) // Match Ingredients and the following return
.+? // Math up to . . .
(?=\rDirections) // a return followed by Directions

This expression matches any paragraphs between Ingredients and Directions. The \r characters (paragraph breaks) must be part of the lookaround to avoid applying the ingredients paragraph style to the Ingredients and Directions headings.

Peter

This article was last modified on March 26, 2016

Comments (0)

Loading comments...