GREP paragraph style question
- This topic has 6 replies, 1 voice, and was last updated 2 months, 3 weeks ago by .
- You must be logged in to reply to this topic.
Learn / Forums / InDesign User Groups / GREP paragraph style question
Learn / Forums / InDesign User Groups / GREP paragraph style question
Tagged: GREP, paragraph styles, styles
Hi Grep gurus… I am trying to make a GREP rule in my paragraph style “Babies”.
I want to apply an existing Character style to part of the 3rd paragraph IF the text matches my GREP in the previous 2 paragraphs.
The format I receive from the authors is in the following format:
BOY
Photos: 1844-48
Jimmy Bob O’CONNOR
…etc
Another different GREP rule will also exist to apply a different style for “GIRL”.
So, the character style “Babies – BOY” will be applied to the name (which bolds and colours it cyan).
That means “BOY” or “GIRL” is important, the next line is not so important, it’s just the Photo reference, then the third paragraph is the important one that needs stylising.
Thanks folks!
I don’t think you can apply a grep style that acts across multiple paragraphs. The GREP style is really focused on patterns within a single paragraph.
However, you could use the GREP tab in the Find/Change dialog box to apply it. For example, you could search for GIRL\r.+\r\K.
and apply a paragraph style to it, like this:
This searches for the first character of a paragraph that is 2 paragraphs down from the word “girl” and applies the paragraph style to the whole paragraph.
Thanks for your reply David!
I’m surprised that’s not a feature (yet!). I can imagine a myriad of uses for using a GREP rule in a paragraph style that reacts to multiple paragraphs inside the story (think, Table of Contents, Top 10 list, Q&A and more).
I hope Adobe can add that to the feature list!
So I guess the next question is, can your Find/Replace solution be coded into a script? That might be a working option! No idea where to start on that though. Can you suggest a forum or resource for figuring out how to do it?
Thanks heaps!
You can probably turn this into a script using the FindChangeByList script. See:
https://creativepro.com/tag/findchangebylist
I know I am late to the game on this one but my ears always perk up at the mention of GREP…
Brett, have you considered using line breaks (AKA soft returns)? You can get the results that you are looking for using soft returns rather than paragraph returns with this GREP string:
GIRL\n(.+\n)+\K.+(?=$)
BONUS: This will work with a minimum of 3 lines (separated by soft returns) and there is no maximum number of lines!
See my screenshot for an example:
On a different note, David, How do you post images on these threads?
It seems that I answered my own question! The image embedded by simply placing the url in the comment… Cool!
Hi!
I am trying to understand how to apply the same character style to many different paragraph styles
problem: I need to use a bold style on names on body copy, table text, dida exc
I am using the GREP style to insert the list of names divided by a pipeline and the character styles applied to it but this means repeating this on each paragraph style…
I tried to apply the character styles with the list of names on a single paragraph syle named GREP and this is going to be the mother of all the other paragraph, but this is not working…
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies allows us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
To provide the best experiences, we and our partners use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us and our partners to process personal data such as browsing behavior or unique IDs on this site and show (non-) personalized ads. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Click below to consent to the above or make granular choices. Your choices will be applied to this site only. You can change your settings at any time, including withdrawing your consent, by using the toggles on the Cookie Policy, or by clicking on the manage consent button at the bottom of the screen.
You have to be logged in to save.
Not a member? Join Today - it's FREE!